111,097
社区成员




private static System.Timers.Timer timeClock = new System.Timers.Timer();
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
timeClock.Elapsed += new System.Timers.ElapsedEventHandler(OnTimeEvent);
timeClock.Interval = timespan; // 这里设置第一次执行时离 8:00:00的时间差
timeClock.AutoReset = true;
timeClock.Enabled = true;
}
private void OnTimeEvent(object sender, System.Timers.ElapsedEventArgs e)
{
// do something
......
timeClock.Interval = 24 * 60 * 1000.0;// 以后每隔24小时执行一次
timeClock.AutoReset = true;
timeClock.Enabled = true;
}
private static System.Timers.Timer timeClock = new System.Timers.Timer();
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
timeClock.Elapsed += new System.Timers.ElapsedEventHandler(OnTimeEvent);
timeClock.Interval = tr.Interval * 24 * 24 * 60 * 1000.0;
timeClock.AutoReset = true;
timeClock.Enabled = true;
}
private void OnTimeEvent(object sender, System.Timers.ElapsedEventArgs e)
{
// do something
}