定時器事件代碼 static void Main(string[] args) {Method();#region 定時器事件 Timer aTimer = new Timer();aTimer.Elapsed += new ElapsedEventHandler(TimedEvent);aTimer.Interval = seconds * 1000; //配置文件中配置的秒數aTimer.Enabled = true;#endregionstring strLine;do{strLine = Console.ReadLine();} while (strLine != null && strLine != "exit");} private static void TimedEvent(object source, ElapsedEventArgs e) {Method(); }
轉載于:https://www.cnblogs.com/zxtceq/p/5667332.html