TimerCallback Delegate

 

Represents the method that handles calls from a Timer.

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

[<ComVisibleAttribute(true)>]
type TimerCallback = 
    delegate of 
        state:Object -> unit

Parameters

state
Type: System.Object

An object containing application-specific information relevant to the method invoked by this delegate, or null.

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.

System_CAPS_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.

The following code example shows how to create the delegate used with the Timer class.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8.1
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: