protected void Application_Start(Object sender, EventArgs e)
{
init();
System.Timers.Timer myTimer=new System.Timers.Timer(3000);
//關聯事件
myTimer.Elapsed += new System.Timers.ElapsedEventHandler(myTimer_Elapsed);
myTimer.AutoReset = true ;
myTimer.Enabled = true ;
}
private void myTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
//獲取當前時間
init();
}
private void init()
{
Application.Lock();
Application["TIMEDEMO"]= DateTime.Now.ToString();
Application.UnLock();
}