WaitHandle.Dispose Method

Definition

Releases all resources used by the current instance of the WaitHandle class.

Overloads

Dispose()

Releases all resources used by the current instance of the WaitHandle class.

Dispose(Boolean)

When overridden in a derived class, releases the unmanaged resources used by the WaitHandle, and optionally releases the managed resources.

Dispose()

Source:
WaitHandle.cs
Source:
WaitHandle.cs
Source:
WaitHandle.cs

Releases all resources used by the current instance of the WaitHandle class.

public void Dispose ();

Implements

Remarks

This method is equivalent to the Close method.

Note

Always call Close or Dispose() before you release your last reference to the WaitHandle. Otherwise, the resources it is using will not be freed.

See also

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

Dispose(Boolean)

Source:
WaitHandle.cs
Source:
WaitHandle.cs
Source:
WaitHandle.cs

When overridden in a derived class, releases the unmanaged resources used by the WaitHandle, and optionally releases the managed resources.

protected virtual void Dispose (bool explicitDisposing);

Parameters

explicitDisposing
Boolean

true to release both managed and unmanaged resources; false to release only unmanaged resources.

Remarks

This method is called by the Close and the Dispose() methods with the explicitDisposing parameter set to true. When the explicitDisposing parameter is true, this method releases all resources held by any managed objects that this WaitHandle object references.

Notes to Inheritors

You should override the Dispose(Boolean) method to release resources allocated in derived classes.

The Close() or Dispose() method can be called multiple times by other objects. When overriding this method, be careful not to reference objects that have been previously disposed in an earlier call to Dispose or Close.

See also

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0