garbage collection - In c#,can we use finalize to dispose the managed source? -


according pattern of how use idisposable, microsoft suggests use finalize release unmanaged source. http://msdn.microsoft.com/en-us/library/system.idisposable%28v=vs.80%29.aspx

but happen if write codes release managed source in finalize? when gc call finalize release managed source, happen?

it's bad practice in general. in finalizer code can't rely on state of object , managed resources - can collected or disposed/finalized already. also, can't rely on order, in clr calls finalize.


Comments

Popular posts from this blog

html - Cut text on left side inside button while centering -

java - Last square of 8x8 grid not drawn, using two nested FOR loops -

What design pattern is this code in Javascript? -