mscorlib(4.0.0.0) API with additions
System.Threading.Timer Class Reference

Provides a mechanism for executing a method on a thread pool thread at specified intervals. This class cannot be inherited.To browse the .NET Framework source code for this type, see the Reference Source. More...

Inheritance diagram for System.Threading.Timer:
[legend]
Collaboration diagram for System.Threading.Timer:
[legend]

Public Member Functions

 Timer (TimerCallback callback, object state, int dueTime, int period)
 Initializes a new instance of the Timer class, using a 32-bit signed integer to specify the time interval. More...
 
 Timer (TimerCallback callback, object state, TimeSpan dueTime, TimeSpan period)
 Initializes a new instance of the Timer class, using T:System.TimeSpan values to measure time intervals. More...
 
 Timer (TimerCallback callback, object state, uint dueTime, uint period)
 Initializes a new instance of the Timer class, using 32-bit unsigned integers to measure time intervals. More...
 
 Timer (TimerCallback callback, object state, long dueTime, long period)
 Initializes a new instance of the Timer class, using 64-bit signed integers to measure time intervals. More...
 
 Timer (TimerCallback callback)
 Initializes a new instance of the T:System.Threading.Timer class with an infinite period and an infinite due time, using the newly created T:System.Threading.Timer object as the state object. More...
 
bool Change (int dueTime, int period)
 Changes the start time and the interval between method invocations for a timer, using 32-bit signed integers to measure time intervals. More...
 
bool Change (TimeSpan dueTime, TimeSpan period)
 Changes the start time and the interval between method invocations for a timer, using T:System.TimeSpan values to measure time intervals. More...
 
bool Change (uint dueTime, uint period)
 Changes the start time and the interval between method invocations for a timer, using 32-bit unsigned integers to measure time intervals. More...
 
bool Change (long dueTime, long period)
 Changes the start time and the interval between method invocations for a timer, using 64-bit signed integers to measure time intervals. More...
 
bool Dispose (WaitHandle notifyObject)
 Releases all resources used by the current instance of T:System.Threading.Timer and signals when the timer has been disposed of. More...
 
void Dispose ()
 Releases all resources used by the current instance of T:System.Threading.Timer. More...
 
- Public Member Functions inherited from System.MarshalByRefObject
object GetLifetimeService ()
 Retrieves the current lifetime service object that controls the lifetime policy for this instance. More...
 
virtual object InitializeLifetimeService ()
 Obtains a lifetime service object to control the lifetime policy for this instance. More...
 
virtual ObjRef CreateObjRef (Type requestedType)
 Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. More...
 

Additional Inherited Members

- Protected Member Functions inherited from System.MarshalByRefObject
MarshalByRefObject MemberwiseClone (bool cloneIdentity)
 Creates a shallow copy of the current T:System.MarshalByRefObject object. More...
 

Detailed Description

Provides a mechanism for executing a method on a thread pool thread at specified intervals. This class cannot be inherited.To browse the .NET Framework source code for this type, see the Reference Source.

Definition at line 12 of file Timer.cs.

Constructor & Destructor Documentation

◆ Timer() [1/5]

System.Threading.Timer.Timer ( TimerCallback  callback,
object  state,
int  dueTime,
int  period 
)

Initializes a new instance of the Timer class, using a 32-bit signed integer to specify the time interval.

Parameters
callbackA T:System.Threading.TimerCallback delegate representing a method to be executed.
stateAn object containing information to be used by the callback method, or null.
dueTimeThe amount of time to delay before callback is invoked, in milliseconds. Specify F:System.Threading.Timeout.Infinite to prevent the timer from starting. Specify zero (0) to start the timer immediately.
periodThe time interval between invocations of callback , in milliseconds. Specify F:System.Threading.Timeout.Infinite to disable periodic signaling.
Exceptions
T:System.ArgumentOutOfRangeExceptionThe dueTime or period parameter is negative and is not equal to F:System.Threading.Timeout.Infinite.
T:System.ArgumentNullExceptionThe callback parameter is null.

Definition at line 28 of file Timer.cs.

◆ Timer() [2/5]

System.Threading.Timer.Timer ( TimerCallback  callback,
object  state,
TimeSpan  dueTime,
TimeSpan  period 
)

Initializes a new instance of the Timer class, using T:System.TimeSpan values to measure time intervals.

Parameters
callbackA delegate representing a method to be executed.
stateAn object containing information to be used by the callback method, or null.
dueTimeThe 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.
periodThe time interval between invocations of the methods referenced by callback . Specify negative one (-1) milliseconds to disable periodic signaling.
Exceptions
T:System.ArgumentOutOfRangeExceptionThe number of milliseconds in the value of dueTime or period is negative and not equal to F:System.Threading.Timeout.Infinite, or is greater than F:System.Int32.MaxValue.
T:System.ArgumentNullExceptionThe callback parameter is null.

Definition at line 52 of file Timer.cs.

◆ Timer() [3/5]

System.Threading.Timer.Timer ( TimerCallback  callback,
object  state,
uint  dueTime,
uint  period 
)

Initializes a new instance of the Timer class, using 32-bit unsigned integers to measure time intervals.

Parameters
callbackA delegate representing a method to be executed.
stateAn object containing information to be used by the callback method, or null.
dueTimeThe amount of time to delay before callback is invoked, in milliseconds. Specify F:System.Threading.Timeout.Infinite to prevent the timer from starting. Specify zero (0) to start the timer immediately.
periodThe time interval between invocations of callback , in milliseconds. Specify F:System.Threading.Timeout.Infinite to disable periodic signaling.
Exceptions
T:System.ArgumentOutOfRangeExceptionThe dueTime or period parameter is negative and is not equal to F:System.Threading.Timeout.Infinite.
T:System.ArgumentNullExceptionThe callback parameter is null.

Definition at line 86 of file Timer.cs.

◆ Timer() [4/5]

System.Threading.Timer.Timer ( TimerCallback  callback,
object  state,
long  dueTime,
long  period 
)

Initializes a new instance of the Timer class, using 64-bit signed integers to measure time intervals.

Parameters
callbackA T:System.Threading.TimerCallback delegate representing a method to be executed.
stateAn object containing information to be used by the callback method, or null.
dueTimeThe amount of time to delay before callback is invoked, in milliseconds. Specify F:System.Threading.Timeout.Infinite to prevent the timer from starting. Specify zero (0) to start the timer immediately.
periodThe time interval between invocations of callback , in milliseconds. Specify F:System.Threading.Timeout.Infinite to disable periodic signaling.
Exceptions
T:System.ArgumentOutOfRangeExceptionThe dueTime or period parameter is negative and is not equal to F:System.Threading.Timeout.Infinite.
T:System.NotSupportedExceptionThe dueTime or period parameter is greater than 4294967294.

Definition at line 101 of file Timer.cs.

◆ Timer() [5/5]

System.Threading.Timer.Timer ( TimerCallback  callback)

Initializes a new instance of the T:System.Threading.Timer class with an infinite period and an infinite due time, using the newly created T:System.Threading.Timer object as the state object.

Parameters
callbackA T:System.Threading.TimerCallback delegate representing a method to be executed.

Definition at line 127 of file Timer.cs.

Member Function Documentation

◆ Change() [1/4]

bool System.Threading.Timer.Change ( int  dueTime,
int  period 
)

Changes the start time and the interval between method invocations for a timer, using 32-bit signed integers to measure time intervals.

Parameters
dueTimeThe amount of time to delay before the invoking the callback method specified when the T:System.Threading.Timer was constructed, in milliseconds. Specify F:System.Threading.Timeout.Infinite to prevent the timer from restarting. Specify zero (0) to restart the timer immediately.
periodThe time interval between invocations of the callback method specified when the T:System.Threading.Timer was constructed, in milliseconds. Specify F:System.Threading.Timeout.Infinite to disable periodic signaling.
Returns
true if the timer was successfully updated; otherwise, false.
Exceptions
T:System.ObjectDisposedExceptionThe T:System.Threading.Timer has already been disposed.
T:System.ArgumentOutOfRangeExceptionThe dueTime or period parameter is negative and is not equal to F:System.Threading.Timeout.Infinite.

Definition at line 165 of file Timer.cs.

◆ Change() [2/4]

bool System.Threading.Timer.Change ( TimeSpan  dueTime,
TimeSpan  period 
)

Changes the start time and the interval between method invocations for a timer, using T:System.TimeSpan values to measure time intervals.

Parameters
dueTimeA T:System.TimeSpan representing the amount of time to delay before invoking the callback method specified when the T:System.Threading.Timer was constructed. Specify negative one (-1) milliseconds to prevent the timer from restarting. Specify zero (0) to restart the timer immediately.
periodThe time interval between invocations of the callback method specified when the T:System.Threading.Timer was constructed. Specify negative one (-1) milliseconds to disable periodic signaling.
Returns
true if the timer was successfully updated; otherwise, false.
Exceptions
T:System.ObjectDisposedExceptionThe T:System.Threading.Timer has already been disposed.
T:System.ArgumentOutOfRangeExceptionThe dueTime or period parameter, in milliseconds, is less than -1.
T:System.NotSupportedExceptionThe dueTime or period parameter, in milliseconds, is greater than 4294967294.

Definition at line 187 of file Timer.cs.

◆ Change() [3/4]

bool System.Threading.Timer.Change ( uint  dueTime,
uint  period 
)

Changes the start time and the interval between method invocations for a timer, using 32-bit unsigned integers to measure time intervals.

Parameters
dueTimeThe amount of time to delay before the invoking the callback method specified when the T:System.Threading.Timer was constructed, in milliseconds. Specify F:System.Threading.Timeout.Infinite to prevent the timer from restarting. Specify zero (0) to restart the timer immediately.
periodThe time interval between invocations of the callback method specified when the T:System.Threading.Timer was constructed, in milliseconds. Specify F:System.Threading.Timeout.Infinite to disable periodic signaling.
Returns
true if the timer was successfully updated; otherwise, false.
Exceptions
T:System.ObjectDisposedExceptionThe T:System.Threading.Timer has already been disposed.

Definition at line 199 of file Timer.cs.

◆ Change() [4/4]

bool System.Threading.Timer.Change ( long  dueTime,
long  period 
)

Changes the start time and the interval between method invocations for a timer, using 64-bit signed integers to measure time intervals.

Parameters
dueTimeThe amount of time to delay before the invoking the callback method specified when the T:System.Threading.Timer was constructed, in milliseconds. Specify F:System.Threading.Timeout.Infinite to prevent the timer from restarting. Specify zero (0) to restart the timer immediately.
periodThe time interval between invocations of the callback method specified when the T:System.Threading.Timer was constructed, in milliseconds. Specify F:System.Threading.Timeout.Infinite to disable periodic signaling.
Returns
true if the timer was successfully updated; otherwise, false.
Exceptions
T:System.ObjectDisposedExceptionThe T:System.Threading.Timer has already been disposed.
T:System.ArgumentOutOfRangeExceptionThe dueTime or period parameter is less than -1.
T:System.NotSupportedExceptionThe dueTime or period parameter is greater than 4294967294.

Definition at line 212 of file Timer.cs.

◆ Dispose() [1/2]

bool System.Threading.Timer.Dispose ( WaitHandle  notifyObject)

Releases all resources used by the current instance of T:System.Threading.Timer and signals when the timer has been disposed of.

Parameters
notifyObjectThe T:System.Threading.WaitHandle to be signaled when the Timer has been disposed of.
Returns
true if the function succeeds; otherwise, false.
Exceptions
T:System.ArgumentNullExceptionThe notifyObject parameter is null.

Definition at line 238 of file Timer.cs.

◆ Dispose() [2/2]

void System.Threading.Timer.Dispose ( )

Releases all resources used by the current instance of T:System.Threading.Timer.

Implements System.IDisposable.

Definition at line 249 of file Timer.cs.


The documentation for this class was generated from the following file: