ウィンドウサービスのonStart()メソッドを設定して、インストール後、最初に午前12時に実行され、時間間隔が正常に機能し、サービスが指定された時間間隔の後に実行されるが、指定された時間に開始されないようにする方法。
public static System.Timers.Timer Timer;
Double _timeinterval = 300 * 1000;// 6 mins
protected override void OnStart(string[] args)
{
Timer = new System.Timers.Timer();
Timer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
Timer.Interval = _timeinterval;
Timer.Enabled = true;
//method call to do operation
}
private void OnTimedEvent(object source, ElapsedEventArgs e)
{
//method call to do operation
}