TimerCallback Delegate

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Represents the method that handles calls from a Timer.

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

public delegate void TimerCallback(
	Object state
)

Parameters

state
Type: System..::..Object
An object containing application-specific information relevant to the method invoked by this delegate, or nullNothingnullptrunita null reference (Nothing in Visual Basic).

Use a TimerCallback delegate to specify the method that is called by a Timer. This method does not execute in the thread that created the timer; it executes in a separate thread pool thread that is provided by the system. The TimerCallback delegate invokes the method once after the start time elapses, and continues to invoke it once per timer interval until the Dispose method is called, or until the Timer..::..Change method is called with the interval value Infinite.

NoteNote

Callbacks can occur after the Dispose()()()() method overload has been called, because the timer queues callbacks for execution by thread pool threads. You can use the Dispose(WaitHandle) method overload to wait until all callbacks have completed.

The timer delegate is specified when the timer is constructed, and cannot be changed. The start time for a Timer is passed in the dueTime parameter of the Timer constructors, and the period is passed in the period parameter. For an example that demonstrates creating and using a TimerCallback delegate, see System.Threading..::..Timer.

Show: