做一个Windows服务,根据需要适当的调整一下定时时长就OK了。
事例代码:
private System.Timers.Timer timer;
private bool firstElapsed;
protected override void OnStart(string[] args)
{
DateTime now = DateTime.Now;
DateTime execTime = new DateTime(now.Year, now.Year, now.Day, 18, 0, 0);
TimeSpan execSpan = execTime - now;
double interval = execSpan.TotalMilliseconds;
timer = new System.Timers.Timer(interval);
timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
}
void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
//TODO:
if(!firstElapsed)
{
firstElapsed = true;
TimeSpan span = new TimeSpan(24, 0, 0);
timer.Interval = span.TotalMilliseconds;
}
}