Why "Finalize method should not reference any other objects" ?
Posted
by mishal153
on Stack Overflow
See other posts from Stack Overflow
or by mishal153
Published on 2010-04-22T06:26:37Z
Indexed on
2010/04/22
6:33 UTC
Read the original article
Hit count: 279
I have been pondering why it is recommended that we should not release managed resources inside finalize. If you see the code example at http://msdn.microsoft.com/en-us/library/system.gc.suppressfinalize.aspx , and search for string "Dispose(bool disposing) executes in two distinct scenarios" and read that comment, you will understand what I mean.
Only possibility I can think of is that it probably has something to do with the fact that it is not possible to predict when finalizer will get called. Does anyone know the right answer ?
thanks, mishal
© Stack Overflow or respective owner