Duplicating "delete this"

  • Thread starter Thread starter Jason
  • Start date Start date
J

Jason

In C++, I can create an object on the heap and have it kill itself when
it's done (i.e. delete this)

In .NET, I have a class which triggers a worker thread. When the worker
thread is finished, I would like to have the object go away. Is there a
..NET/C#-proper way of doing this?

Thanks in advance...
 
Hi...

The pattern is:

myObject.Dispose(); // many classes implement IDisposable
myObject = null;

John Puopolo
 
In C++, I can create an object on the heap and have it kill itself when
it's done (i.e. delete this)

In .NET, I have a class which triggers a worker thread. When the worker
thread is finished, I would like to have the object go away. Is there a
.NET/C#-proper way of doing this?

Thanks in advance...

Never mind, I found out about ThreadPools and can use that.
 
Back
Top