我有一个Windows服务,我需要做两件事,每15分钟一次,每天一次。使用2个定时器来执行此操作是否有效,类似于下面的内容?
protected override void OnStart(string[] args)
{
Console.WriteLine("start");
this.regularTimer = new System.Timers.Timer(300000D);
this.regularTimer.AutoReset = true;
this.regularTimer.Elapsed += new System.Timers.ElapsedEventHandler(this.DoRegular);
this.regularTimer.Start();
this.longTimer = new System.Timers.Timer(86400000D);
this.longTimer.AutoReset = true;
this.longTimer.Elapsed += new System.Timers.ElapsedEventHandler(this.DoLongRunning);
this.longTimer.Start();
}