Timer Constructor (TimerCallback^)
Initializes a new instance of the Timer class with an infinite period and an infinite due time, using the newly created Timer object as the state object.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- callback
-
Type:
System.Threading::TimerCallback^
A TimerCallback delegate representing a method to be executed.
Call this constructor when you want to use the Timer object itself as the state object. After creating the timer, use the Change method to set the interval and due time.
This constructor specifies an infinite due time before the first callback and an infinite interval between callbacks, in order to prevent the first callback from occurring before the Timer object is assigned to the state object.
The method specified for callback should be reentrant, because it is called on ThreadPool threads. The method can be executed simultaneously on two thread pool threads if the timer interval is less than the time required to execute the method, or if all thread pool threads are in use and the method is queued multiple times.
The following code example creates a new timer, using the timer itself as the state object. The Change method is used to start the timer. When the timer callback occurs, the state object is used to turn the timer off.
Available since 2.0
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0