Unlike many other environments .NET does not have deterministic
finalization. Your objects are not neccesarily destroyed when all references
to them are released. That is simply the earliest possible time at which
they can be destroyed. The .NET Garbage Collector will decide when to
destroy your objects, and the destructor will be called then. This is why we
have Dispose, to ensure that expensive resources like database connections
and handles can be closed at a predictable and early time.
For managed resources it is generally unneccesary to implement both a
destructor and a Dispose method. For unmanaged resources see this
http://msdn.microsoft.com/library/de...posemethod.asp
for some reccommendations.
"Claire" <cc@hotmai1.com> wrote in message
news:37*************@individual.net...
I've also got a class destructor in addition to a dispose. I don't
actually use it because my cleanup code is in the Dispose() method but I
notice that the breakpoint I placed in there wasn't getting called (code
line I added to destructor for testing was timer = null) So how can I be
sure my object has been destroyed?
I noticed that the final destructor only got called when the application
terminated. As I'd created/disposed of several instances of the object
during the course of running the app, there were several breaks in the
destructor right at the end. So something still isn't right.