Timer.Change Method (TimeSpan, TimeSpan)
Changes the start time and the interval between method invocations for a Timer object (timer), using TimeSpan values to specify time intervals.
Namespace: System.Threading
Assembly: mscorlib (in mscorlib.dll)
Syntax
[MethodImplAttribute]
public bool Change (
TimeSpan dueTime,
TimeSpan period
)
Parameters
- dueTime
A TimeSpan object that represents the amount of time, in milliseconds, you want the system to delay before invoking the callback method specified when the current timer was constructed. Specify -1 milliseconds to prevent the timer from restarting. Specify 0 (zero) to restart the timer immediately. - period
The time interval, in milliseconds, between invocations of the callback method specified when the current timer was constructed. Specify -1 milliseconds to disable periodic signaling.
Return Value
true if the current timer has not been disposed; otherwise, false.
Remarks
To keep CPU and memory usage to a minimum, timers in the .NET Micro Framework operate slightly differently than do timers in the .NET Framework. Specifically, setting both the dueTime and period parameters does not cause a timer to be queued, as it does in the .NET Framework. Instead, calling the Change method throws an exception indicating that the timer has been retriggered.
It is possible for the common language runtime (CLR) to reuse a timer after the timer has been released by the Dispose method. As a result, the Change method may return true even though your application has already called Dispose on it.
Version Information
Available in the .NET Micro Framework versions 2.0, 2.5, 3.0, 4.0, 4.1, and 4.2.