It's up to clients of the class implementing
IDisposable to make sure they call the
Dispose method when they are finished using the object. There is nothing in the CLR that directly searches objects for a
Dispose method to invoke.
It's not necessary to implement a finalizer if your object only contains managed resources. Be sure to call
Dispose on all of the objects that your class uses when you implement your own
It's recommended to make the class safe against multiple calls to
Dispose, although it should ideally be called only once. This can be achieved by adding a
private bool variable to your class and setting the value to
true when the
Dispose method has run.