日期:2014-05-16 浏览次数:21098 次
System.Timers.Timer timer;
public void TimeTest()
{
timer = new System.Timers.Timer();
timer.Interval = 1000;
timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
timer.Start();
Console.ReadLine();
}
void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
Console.WriteLine("timer 停止啦");
Thread t = new Thread(new ThreadStart(() => { Thread.Sleep(1000); timer.Start(); Console.WriteLine("timer 启动啦"); }));
t.Start();
timer.Stop();
}
this.Invoke(
(MethodInvoker)delegate
{
timer1.Start();
});