使用
Timer该类。
public static void Main(){ System.Timers.Timer aTimer = new System.Timers.Timer(); aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent); aTimer.Interval = 5000; aTimer.Enabled = true; Console.WriteLine("Press 'q' to quit the sample."); while(Console.Read() != 'q');} // Specify what you want to happen when the Elapsed event is raised. private static void onTimedEvent(object source, ElapsedEventArgs e) { Console.WriteLine("Hello World!"); }该
Elapsed事件将被升高的毫秒每X量,由指定的
Interval计时器对象上属性。它将调用
EventHandler您指定的方法。在上面的示例中,它是
OnTimedEvent。


![实施“计时器”的最佳方法是什么?[重复] 实施“计时器”的最佳方法是什么?[重复]](http://www.mshxw.com/aiimages/31/388006.png)
