[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Provides a mechanism for executing a method at specified intervals. This class cannot be inherited.
Assembly: mscorlib (in mscorlib.dll)
Thetype exposes the following members.
|Timer(TimerCallback, Object, Int32, Int32)||Initializes a new instance of the Timer class, using a 32-bit signed integer to specify the time interval.|
|Timer(TimerCallback, Object, TimeSpan, TimeSpan)||Initializes a new instance of the Timer class, using TimeSpan values to measure time intervals.|
|Change(Int32, Int32)||Changes the start time and the interval between method invocations for a timer, using 32-bit signed integers to measure time intervals.|
|Change(TimeSpan, TimeSpan)||Changes the start time and the interval between method invocations for a timer, using TimeSpan values to measure time intervals.|
|Dispose||Releases all resources used by the current instance of .|
|Equals(Object)||Determines whether the specified Object is equal to the current Object. (Inherited from Object.)|
|GetHashCode||Serves as a hash function for a particular type. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
Use a TimerCallback delegate to specify the method you want the to execute. The timer delegate is specified when the timer is constructed, and cannot be changed. The method does not execute on the thread that created the timer; it executes on a thread supplied by the system.
When you create a timer, you can specify an amount of time to wait before the first execution of the method (due time), and an amount of time to wait between subsequent executions (period). You can change these values, or disable the timer, using the Change method.
When a timer is no longer needed, use the method to free the resources held by the timer. Note that 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 method overload to wait until all callbacks have completed.
The callback method executed by the timer should be reentrant, because it is called on threads. The callback can be executed simultaneously on two thread pool threads if the timer interval is less than the time required to execute the callback, or if all thread pool threads are in use and the callback is queued multiple times.