Hi friends,
I want to know that what do you mean by deterministic finalization in C#? How do I get deterministic finalization in C#?
Loading
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.
George TourtsinakisPosted Oct 28, 2015, 8:05 AM
VulpesPosted Feb 7, 2012, 11:07 AM
This is not possible in C# and .NET generally. All you can do is to set all references to a managed object to null and wait for the garbage collector to get around to destroying the object.
However, you can force a garbage collection of all such objects (or all such objects in a particular generation) by calling the GC.Collect method:
http://msdn.microsoft.com/en-us/library/xe0c2357.aspx
If an object uses unmanaged resources, you can also reclaim those resources immediately by implementing the IDisposable interface and calling the Dispose method on the object (or use the 'using' statement which does this automatically) without waiting for the managed object itself to be destroyed.