O'Reilly logo

C# in a Nutshell by Peter Drayton, Ted Neward, Ben Albahari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Timer

Synopsis

This class raises an event at regular intervals. It is a server-based timer, which provides much more accuracy than normal Windows timers and ensures that the event is raised at the proper time. To use a Timer, set the Elapsed event, the Interval property, Enabled to true. Start() and Stop() provide shortcuts, which respectively assign true and false to Enabled. AutoReset allows you to specify whether the event should be raised only once or periodically. The default is true, which makes the Timer periodic.

public class Timer : System.ComponentModel.Component : System.ComponentModel.ISupportInitialize {
// Public Constructors
   public method Timer();  
   public method Timer(double interval);  
// Public Instance Properties
   public field bool AutoReset{set; get; } 
   public field bool Enabled{set; get; } 
   public field double Interval{set; get; } 
   public override field ISite Site{set; get; }  // overrides System.ComponentModel.Component
   public field ISynchronizeInvoke SynchronizingObject{set; get; } 
// Public Instance Methods
   public method void BeginInit();  // implements System.ComponentModel.ISupportInitialize
   public method void Close();  
   public method void EndInit();    // implements System.ComponentModel.ISupportInitialize
   public method void Start();  
   public method void Stop();  
// Protected Instance Methods
   protected override method void Dispose(bool disposing); // overrides System.ComponentModel.Component
                  // Events
   public event field ElapsedEventHandler Elapsed;  
}

Hierarchy

System.Object ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required