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

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -