BCL mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 4.0.0.0 All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe. System.MarshalByRefObject System.IDisposable

Provides a mechanism for executing methods at specified intervals.

A delegate is used to specify the methods associated with a . The methods do not execute in the thread that created the timer; they execute in a separate thread that is automatically allocated by the system. The timer delegate is specified when the timer is constructed, and cannot be changed.

When creating a timer, the application specifies an amount of time to wait before the first invocation of the delegate methods (due time), and an amount of time to wait between subsequent invocations (period). A timer invokes its methods once when its due time elapses, and invokes its methods once per period thereafter. These values can be changed, or the timer disabled using the

method.

When a timer is no longer needed, use the method to free the resources held by the timer.

The following example demonstrates the features of the class.

`using System; using System.Threading; class TimerExampleState { public int counter = 0; public Timer tmr; } class App { public static void Main() { TimerExampleState s = new TimerExampleState(); // Create the delegate that invokes methods for the timer. TimerCallback timerDelegate = new TimerCallback(CheckStatus); // Create a timer that waits one second, then invokes every second. Timer timer = new Timer(timerDelegate, s, 1000, 1000); // Keep a handle to the timer, so it can be disposed. s.tmr = timer; // The main thread does nothing until the timer is disposed. while (s.tmr != null) Thread.Sleep(0); Console.WriteLine("Timer example done."); } // The following method is called by the timer's delegate. static void CheckStatus(Object state) { TimerExampleState s = (TimerExampleState) state; s.counter++; Console.WriteLine("{0} Checking Status {1}.",DateTime.Now.TimeOfDay, s.counter); if (s.counter == 5) { // Shorten the period. Wait 10 seconds to restart the timer. (s.tmr).Change(10000,100); Console.WriteLine("changed..."); } if (s.counter == 10) { Console.WriteLine("disposing of timer..."); s.tmr.Dispose(); s.tmr = null; } } }`

An example of some output is

10:51:40.5809015 Checking Status 1.

10:51:41.5823515 Checking Status 2.

10:51:42.5838015 Checking Status 3.

10:51:43.5852515 Checking Status 4.

10:51:44.5867015 Checking Status 5.

changed...

10:51:54.5911870 Checking Status 6.

10:51:54.6913320 Checking Status 7.

10:51:54.7914770 Checking Status 8.

10:51:54.8916220 Checking Status 9.

10:51:54.9917670 Checking Status 10.

disposing of timer...

Timer example done.

The exact timings returned by this example will vary.

- Constructor
  To be added.
  To be added.
  To be added.
  2.0.0.0
  4.0.0.0
- Constructor
  A delegate.
  A containing application-specific information relevant to the methods invoked by , or .
  A containing the amount of time to delay before invokes its methods, in milliseconds. Specify to prevent the timer from starting. Specify zero to start the timer immediately.
  A containing the time interval between invocations of the methods referenced by in milliseconds. Specify to disable periodic signaling.

  Constructs and initializes a new instance of the class.

  invokes its methods once after elapses, and then invokes its methods each time the time interval elapses.

  If is zero, performs its first invocation immediately. If is , does not invoke its methods; the timer is disabled, but can be re-enabled using the method.

  If is zero or and is not , invokes its methods exactly once; the periodic behavior of the timer is disabled, but can be re-enabled using the method.

  or is negative and is not equal to .
  is a reference.
  0
  1.0.5000.0
  2.0.0.0
  4.0.0.0
- Constructor
  To be added.
  To be added.
  To be added.
  To be added.
  To be added.
  To be added.
  1.0.5000.0
  2.0.0.0
  4.0.0.0
- Constructor
  A delegate.
  A containing application-specific information relevant to the methods invoked by , or .
  A set to the amount of time to delay before invokes its methods. Set the value to milliseconds to prevent the timer from starting. Specify zero to start the timer immediately.
  A set to the time interval between invocations of the methods referenced by . Set the value to milliseconds to disable periodic signaling.

  Constructs and initializes a new instance of the class.

  The delegate invokes its methods once after elapses, and then invokes its methods each time the time interval elapses.

  If in milliseconds, is zero, performs its first invocation immediately. If is , no method invocation occurs. The timer is disabled, but can be re-enabled using the method.

  If is zero or milliseconds and is not , invokes its methods exactly once. The periodic behavior of the timer is disabled, but can be re-enabled using the method.

  The number of milliseconds in the value of or is negative and not equal to , or is greater than .
  is a reference.
  0
  1.0.5000.0
  2.0.0.0
  4.0.0.0
- Constructor
  System.CLSCompliant(false)
  To be added.
  To be added.
  To be added.
  To be added.
  To be added.
  To be added.
  1.0.5000.0
  2.0.0.0
  4.0.0.0
- Method
  System.Boolean `` `` A containing the amount of time to delay before the delegate specified at construction time invokes its methods, in milliseconds. Specify to prevent the timer from restarting. Specify zero to restart the timer immediately. A containing the time interval between invocations of the methods referenced by the delegate specified at construction time in milliseconds. Specify to disable periodic signaling.

  Changes the start time and interval between method invocations for a timer.

  if the current instance has not been disposed; otherwise, .

  The delegate specified at construction time invokes its methods once after elapses, and then invokes its methods each time the time interval elapses.

  If is zero, the delegate specified at construction time performs its next invocation immediately. If is , no method invocation occurs. The timer is disabled, but can be re-enabled by calling this method and specifying a non-negative value for .

  If is zero or and is not , the delegate specified at construction time invokes its methods exactly once. The periodic behavior of the timer is disabled, but can be re-enabled by calling this method and specifying a positive value for .

  or is negative and is not equal to . 0 1.0.5000.0 2.0.0.0 4.0.0.0
- Method
  System.Boolean `` `` To be added. To be added. To be added. To be added. To be added. 1.0.5000.0 2.0.0.0 4.0.0.0
- Method
  System.Boolean `` `` A set to the amount of time to delay before the delegate specified at construction time invokes its methods. Specify milliseconds to prevent the timer from restarting. Specify zero to restart the timer immediately. A set to the time interval between invocations of the methods referenced by the delegate specified at construction time. Specify milliseconds to disable periodic signaling.

  Changes the start time and interval between method invocations for a timer.

  if the current instance has not been disposed; otherwise, .

  The delegate specified at construction time invokes its methods once after elapses, and then invokes its methods each time the time interval elapses.

  If in milliseconds, is zero, the delegate specified at construction time performs its next invocation immediately. If is milliseconds, no method invocation occurs. The timer is disabled, but can be re-enabled by calling this method and specifying a non-negative value for .

  If is zero or milliseconds and is not milliseconds, the delegate specified at construction time invokes its methods exactly once. The periodic behavior of the timer is disabled, but can be re-enabled by calling this method and specifying a positive value for .

  or is negative and is not equal to . 0 1.0.5000.0 2.0.0.0 4.0.0.0
- Method
  System.Boolean `` `` To be added. To be added. To be added. To be added. To be added. 1.0.5000.0 2.0.0.0 4.0.0.0 System.CLSCompliant(false)
- Method
  System.Void

  Releases the resources held by the current instance.

  This method is implemented to support the interface.

  0
  1.0.5000.0
  2.0.0.0
  4.0.0.0
- Method
  System.Boolean `` Specifies a to be signaled when the timer has been disposed of.

  Releases the resources held by the current instance.

  if the call succeeds; otherwise, .

  When this method completes, the specified by is signaled.

  This method calls to prevent the garbage collector from finalizing the current instance.

  is . 0 1.0.5000.0 2.0.0.0 4.0.0.0
0 System.Runtime.InteropServices.ComVisible(true)