Mono Class Library: System Namespace

System.IDisposable

Implemented by classes that require explicit control over resource cleanup. [Edit]

See Also: IDisposable Members

[System.Runtime.InteropServices.ComVisible(true)]
public interface IDisposable

Remarks

Objects that need to free resources that cannot safely be reclaimed by the garbage collector implement the IDisposable interface.

It is a version breaking change to add the IDisposable interface to an existing class, as it changes the semantics of the class.

Note: IDisposable contains the IDisposable.Dispose method. The consumer of an object should call this method when the object is no longer needed. The IDisposable interface is generally provided for the release of unmanaged resources that need to be reclaimed in some order or time dependent manner. It is important to note that the actual release of these resources happens at the first call to IDisposable.Dispose for any given object that supports this interface. Programmers should take care to pair the creation of objects that implement IDisposable with at most one invocation of the Dispose method. Though it is legal to invoke Dispose more than once, if this happens it might indicate the presence of a bug since such an object is usually rendered otherwise unusable after the first Dispose invocation.

[Edit]

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0