Namespace: System.Threading
Timer
Provides a mechanism for executing a method on a thread pool thread at specified intervals. This class cannot be inherited.
Methods (9)
Timer(Threading.TimerCallback,Object,TimeSpan,TimeSpan)Constructor
Initializes a new instance of the Timer class, using TimeSpan values to measure time intervals.
| Parameter | Description |
|---|---|
| callback | A delegate representing a method to be executed. |
| state | An object containing information to be used by the callback method, or null. |
| dueTime | The amount of time to delay before the callback parameter invokes its methods. Specify negative one (-1) milliseconds to prevent the timer from starting. Specify zero (0) to start the timer immediately. |
| period | The time interval between invocations of the methods referenced by callback. Specify negative one (-1) milliseconds to disable periodic signaling. |
Timer(Threading.TimerCallback,Object,Int64,Int64)Constructor
Initializes a new instance of the Timer class, using 64-bit signed integers to measure time intervals.
| Parameter | Description |
|---|---|
| callback | A TimerCallback delegate representing a method to be executed. |
| state | An object containing information to be used by the callback method, or null. |
| dueTime | The amount of time to delay before callback is invoked, in milliseconds. Specify Infinite to prevent the timer from starting. Specify zero (0) to start the timer immediately. |
| period | The time interval between invocations of callback, in milliseconds. Specify Infinite to disable periodic signaling. |
Timer(Threading.TimerCallback,Object,Int32,Int32)Constructor
Initializes a new instance of the Timer class, using a 32-bit signed integer to specify the time interval.
| Parameter | Description |
|---|---|
| callback | A TimerCallback delegate representing a method to be executed. |
| state | An object containing information to be used by the callback method, or null. |
| dueTime | The amount of time to delay before callback is invoked, in milliseconds. Specify Infinite to prevent the timer from starting. Specify zero (0) to start the timer immediately. |
| period | The time interval between invocations of callback, in milliseconds. Specify Infinite to disable periodic signaling. |
Timer(Threading.TimerCallback,Object,UInt32,UInt32)Constructor
Initializes a new instance of the Timer class, using 32-bit unsigned integers to measure time intervals.
| Parameter | Description |
|---|---|
| callback | A delegate representing a method to be executed. |
| state | An object containing information to be used by the callback method, or null. |
| dueTime | The amount of time to delay before callback is invoked, in milliseconds. Specify Infinite to prevent the timer from starting. Specify zero (0) to start the timer immediately. |
| period | The time interval between invocations of callback, in milliseconds. Specify Infinite to disable periodic signaling. |
Timer(Threading.TimerCallback)Constructor
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.
| Parameter | Description |
|---|---|
| callback | A TimerCallback delegate representing a method to be executed. |
bool Change(TimeSpan,TimeSpan)
Changes the start time and the interval between method invocations for a timer, using TimeSpan values to measure time intervals.
| Parameter | Description |
|---|---|
| dueTime | A TimeSpan representing the amount of time to delay before invoking the callback method specified when the Timer was constructed. Specify negative one (-1) milliseconds to prevent the timer from restarting. Specify zero (0) to restart the timer immediately. |
| period | The time interval between invocations of the callback method specified when the Timer was constructed. Specify negative one (-1) milliseconds to disable periodic signaling. |
Returns: true if the timer was successfully updated; otherwise, false.
bool Change(Int64,Int64)
Changes the start time and the interval between method invocations for a timer, using 64-bit signed integers to measure time intervals.
| Parameter | Description |
|---|---|
| dueTime | The amount of time to delay before the invoking the callback method specified when the Timer was constructed, in milliseconds. Specify Infinite to prevent the timer from restarting. Specify zero (0) to restart the timer immediately. |
| period | The time interval between invocations of the callback method specified when the Timer was constructed, in milliseconds. Specify Infinite to disable periodic signaling. |
Returns: true if the timer was successfully updated; otherwise, false.
bool 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.
| Parameter | Description |
|---|---|
| dueTime | The amount of time to delay before the invoking the callback method specified when the Timer was constructed, in milliseconds. Specify Infinite to prevent the timer from restarting. Specify zero (0) to restart the timer immediately. |
| period | The time interval between invocations of the callback method specified when the Timer was constructed, in milliseconds. Specify Infinite to disable periodic signaling. |
Returns: true if the timer was successfully updated; otherwise, false.
bool Change(UInt32,UInt32)
Changes the start time and the interval between method invocations for a timer, using 32-bit unsigned integers to measure time intervals.
| Parameter | Description |
|---|---|
| dueTime | The amount of time to delay before the invoking the callback method specified when the Timer was constructed, in milliseconds. Specify Infinite to prevent the timer from restarting. Specify zero (0) to restart the timer immediately. |
| period | The time interval between invocations of the callback method specified when the Timer was constructed, in milliseconds. Specify Infinite to disable periodic signaling. |
Returns: true if the timer was successfully updated; otherwise, false.