Timers
using System.Timers;
protected void Application_Start(Object sender, EventArgs e)
{
System.Timers.Timer timer = new System.Timers.Timer(1000);
//AutoReset 属性为 true 时,每隔指定时间循环一次;
//如果为 false,则只执行一次。
timer.AutoReset = true;
timer.Enabled = true;
timer.Elapsed += new System.Timers.ElapsedEventHandler(this.setTime);
Application.Lock();
Application["time"] = DateTime.Now.ToString();
Application.UnLock();
}
public void setTime(Object sender, ElapsedEventArgs e)
{
Application.Lock();
Application["time"] = DateTime.Now.ToString();
Application.UnLock();
}