Regarding functions
Why we use finalize and dispose functions separately
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Prabhu RajaPosted Sep 19, 2011, 1:12 AM
Finalize () is called by Garbage Collector implicitly to free unmanaged resources. The garbage collector calls this method at some point after there are no longer valid references to the object. There are some resources like windows handles, database connections which cannot be collected by the garbage collector.
Therefore the programmer needs to call Dispose() method of IDisposable interface. Dispose () of IDisposable interface is called by the programmer to explicitly release resources when they are no longer being used. Dispose () can be called even if other references to the object are alive.
Thank You
Satish BhatPosted Sep 19, 2011, 12:56 AM
Pravin MorePosted Sep 19, 2011, 12:48 AM
There is diiference between finalize and dispose......
see Dispose() is normal method by which resourses are freed up from normal user code like internally via Close() method. Finalize() is used to clean resources in the cases when Dispose() is not get called like e.g case when there is some programming error.
hope m right....
Thanx,
Pravin.