Question Object life cycle - what is the order of events?

jmadden93

New member
Joined
Jan 13, 2010
Messages
1
Programming Experience
5-10
I'm trying to better understand the life cycle of an object in the .Net framework. My companies Intranet has some custom classes that were written by a vendor that I'm trying to make some modifications to. Specifically I want to set some variables & hashtables to null when use of the object is done. For now I have this in the dispose event.

Is there any info you can point to that would be good reading on the life cycle of an object in the .Net framework? I.e. what order do the events fire in? OnInit, Initialize, finalize, Dispose, etc. I have the ASP.net page lifecycle but I'm not looking for that.

If you can point me to some reference material I'd appreciate it.
Thanks!
 
Last edited:
I'm trying to better understand the life cycle of an object in the .Net framework. My companies Intranet has some custom classes that were written by a vendor that I'm trying to make some modifications to. Specifically I want to set some variables & hashtables to null when use of the object is done. For now I have this in the dispose event.

Is there any info you can point to that would be good reading on the life cycle of an object in the .Net framework? I.e. what order do the events fire in? OnInit, Initialize, finalize, Dispose, etc. I have the ASP.net page lifecycle but I'm not looking for that.

If you can point me to some reference material I'd appreciate it.
Thanks!
Implementing IDisposable is the correct way to do it if you're making use of unmanaged objects or managed objects that implement IDisposable.

If you're not doing either of those, then no clean-up is required. When memory is needed, the garbage collector will run and collect anything that is out-of-scope.

I do want to point out that setting variables to null has no effect in .NET. The garbage collector doesn't work the same way that it did in VB6.
 
Back
Top