Object destruction event

  • Thread starter Thread starter Chewie2112
  • Start date Start date
C

Chewie2112

Is there a way in VB to get a notification when an object
is destroyed when that object does not have a terminate
event?

I am using a control that does not have a notification
event when it is destroyed. I need to know when the
object is destroyed so I can do some cleanup.

Thanks Chewie2112
 
There is much that can be (and has been) said on this. Look for help on
Garbage Collection, The Dispose Method, The Finalize Method.

In a nutshell, in .NET you don't/won't know for sure when an object is
removed from the memory heap. You will know when it falls out of scope and
the Dispose method will fire at that point. Finalize with fire when the
object is actually being removed from the heap, but since you don't know for
sure when that is, you want to be very careful about using it.
 
Thanks for the quick reply. But I noticed I posted to the
DotNet group instead of the General VB group (I am not
using .Net). Sorry for waisting your time.

Chewie2112.
 
Back
Top