C# System.Timers Demo

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")}");
        }

 

posted @ 2019-10-31 11:46  FredGrit  阅读(264)  评论(0编辑  收藏  举报