This documentation is archived and is not being maintained.

Timer.Dispose Method (WaitHandle)

Releases all resources used by the current instance of Timer and signals when the timer has been disposed of.

Namespace:  System.Threading
Assembly:  mscorlib (in mscorlib.dll)

public bool Dispose(
	WaitHandle notifyObject


Type: System.Threading.WaitHandle

The WaitHandle to be signaled when the Timer has been disposed of.

Return Value

Type: System.Boolean
true if the function succeeds; otherwise, false.


The notifyObject parameter is null.

Calling Dispose allows the resources used by the Timer to be reallocated for other purposes. For more information about Dispose, see Cleaning Up Unmanaged Resources.

When this method completes, it signals the WaitHandle specified by the notifyObject parameter. Use this overload of the Dispose method if you want to be able to block until you are certain that the timer has been disposed. The timer is not disposed until all currently queued callbacks have completed.


If the callback uses the Change method to set the dueTime parameter to zero, a race condition can occur when the Dispose(WaitHandle) method overload is called: If the timer queues a new callback before the Dispose(WaitHandle) method overload detects that there are no callbacks queued, Dispose(WaitHandle) continues to block; otherwise, the timer is disposed while the new callback is being queued, and an ObjectDisposedException is thrown when the new callback calls the Change method.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0