Language

DisposableObject.Dispose Method

Definition

Overloads

Name Description
Dispose()

Releases all resources used by this object.

Dispose(Boolean)

Releases the resources used by this object.

Dispose()

Releases all resources used by this object.

public void Dispose();
abstract member Dispose : unit -> unit
override this.Dispose : unit -> unit

Implements

Remarks

This method releases the resources used by this object, and marks the object as disposed. Once developers have invoked the Dispose() method, the object is no longer useful and developers should no longer make any calls to it.

Calling this method when the application is finished using this object ensures that all external resources used by this object are released as soon as possible.

Applies to

Dispose(Boolean)

Releases the resources used by this object.

protected virtual void Dispose(bool disposing);
abstract member Dispose : bool -> unit
override this.Dispose : bool -> unit

Parameters

disposing
Boolean

If set to true, the method is invoked directly and disposes managed and unmanaged resources. If set to false, the method is called by the garbage collector finalizer and should only release unmanaged resources.

Remarks

This method is called by both the Dispose() method and the object finalizer. When invoked by the Dispose() method, the disposing parameter is set to true. When invoked by the object finalizer, on the finalizer thread, the disposing parameter is set to false.

Subclasses should override this method to release any resources they hold, and then call the base implementation.

Applies to