C# System.Timers Demo
程序员文章站
2022-06-10 19:33:21
static void Main(string[] args) { SystemTimersDemo(); Console.ReadLine(); } static void SystemTimersDemo() { System.Timers.Timer timer = new System.Ti... ......
static void main(string[] args) { systemtimersdemo(); console.readline(); } static void systemtimersdemo() { system.timers.timer timer = new system.timers.timer(1000); timer.elapsed += timer_elapsed; timer.autoreset = true; timer.enabled = true; } private static void timer_elapsed(object sender, system.timers.elapsedeventargs e) { console.writeline($"the elapsed event was raised at {e.signaltime.tostring("yyyymmddhhmmssffff")}"); }