Finalizers
Resources of an object are cleaned up in a Finalize method. Before an object is removed from memory, the Finalize method is called to allow for cleanup that is related to the object. Finalize methods are called finalizers. Every object inherits the Finalize method from the System.Object type. Here is the signature of the Finalize method:
protected virtual void Finalize()
Finalizers are not called programmatically; they are called automatically during the garbage collection cycle. Garbage collection is nondeterministic, which means that the finalizer may not be called immediately after the object no longer is needed. Unmanaged resources that might be released in a finalizer, such as files, database connections, and devices, might not be ...
Get Programming Microsoft® Visual C#® 2008: The Language now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.