Class_Terminate

binay

New member
Joined
Nov 8, 2006
Messages
1
Programming Experience
Beginner
dear sir,
I am using vb.net 2003. Class_initialize and class_terminate are two event of class in Vb.In vb.net PublicSubNew() and ProtectedOverridesSub Finalize() do the same work as class_initailize and class_terminate. But, ProtectedOverridesSub Finalize() event do not fire when class is closed.

I have put some code in class_terminate in vb and it works fine.But , class_terminate event of the vb.net do not fire.

If anyone has knowledge of it then it will be very helpful to me.
Thank you.
 
Finalize is not an event. It is a method and you should not be putting any code in it. If your class requires cleanup then you should implement the IDisposable interface and put your code in the Dispose method. The only thing your Finalize method does is call Dispose. The purpose of the Finalize method is to be called by the garbage collector to ensure that proper cleanup occurs if the user code hasn't called Dispose explicitly. Properly written code should ALWAYS call Dispose explicitly on objects that support it so the Finalize fail safe should never really need to be invoked. I suggest that you do some reading on destructors and object disposal.

http://search.msdn.microsoft.com/search/default.aspx?siteId=0&tab=0&query=dispose+finalize
 
Back
Top