|
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(); }
|