【转】C# 定时器事件(设置时间间隔,间歇性执行某一函数,控制台程序)

using System.Timers;
定时器事件代码 static void Main(string[] args) { Method(); #region 定时器事件 Timer aTimer = new Timer(); aTimer.Elapsed += new ElapsedEventHandler(TimedEvent); aTimer.Interval = 1000; aTimer.Enabled = true; #endregion string strLine; do { strLine = Console.ReadLine(); } while (strLine != null && strLine != "exit"); } private static void TimedEvent(object source, ElapsedEventArgs e) { Method(); }

  

原文地址:https://www.cnblogs.com/ingen42/p/7738657.html