April 2008
Intermediate to advanced
704 pages
17h 49m
English
Problem
You need to create a class that references unmanaged resources and provide a mechanism for users of the class to free those unmanaged resources deterministically.
Solution
Implement the System.IDisposable interface, and release the unmanaged resources when client code calls the IDisposable.Dispose method.
How It Works
An unreferenced object continues to exist on the managed heap and consume resources until the garbage collector releases the object and reclaims the resources. The garbage collector will automatically free managed resources (such as memory), but it will not free unmanaged resources (such as file handles and database connections) referenced by managed objects. If an object contains data ...
Read now
Unlock full access