System.Threading.TimerCallback Delegate

Assembly: Mscorlib.dll
Namespace: System.Threading
Summary
Represents the method that will handle the state of a Timer.
C# Syntax:
[Serializable]
public delegate void TimerCallback(object state);
Parameters:
The declaration of your event handler must have the same parameters as the TimerCallback delegate declaration.

state

The source of the event. This is an object containing application-specific information relevant to the methods invoked by this delegate, or null.

Remarks
Use a TimerCallback delegate to specify the methods associated with a Timer. The methods do not execute in the thread that created the timer; they execute in a separate thread that is automatically allocated by the system. The TimerCallback delegate invokes its methods once after the start time elapses, and continues invoking its methods once per period until the Timer.Dispose method is called.

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 the Timer class.

When you create a TimerCallback delegate, you identify the method that will handle the event. To associate the event handler with your event, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see the conceptual topic at MSDN: eventsdelegates.

See also:
System.Threading Namespace | Timer | ThreadPool | MSDN: eventsdelegates

Hierarchy:

Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.