C# Timer定时器用法
System.Timers.Timer timer1 = new System.Timers.Timer(); timer1.Elapsed += new System.Timers.ElapsedEventHandler((obj, eventArg) => { Console.WriteLine("aaa"); }); timer1.Interval = 2000;//毫秒 1秒=1000毫秒 timer1.Enabled = true;//必须加上 timer1.AutoReset = false;//执行一次 false,一直执行true Console.ReadKey();