上面的代码我已转成C#代码,并......
上面的代码我已转成C#代码,并没有达到我想要的settimeout效果,我该怎么办?

C#版:(加入global.asax 中使用)

      protected void Application_Start(Object sender, EventArgs e)
      {
         Application["sj"] = "sj001";

         //DataSet DS =new DataSet();


         //创建一个计时器,单位:毫秒  
         Timer aTimer = new Timer(4000);

         //将 Fresher 指定为计时器的 Elapsed 事件处理程序
         //示例:this.timer1.Elapsed += new System.Timers.ElapsedEventHandler(this.timer1_Elapsed);
         //对于简单的事件声明,如:public event EventHandler Click;

//         EventHandler aTimer_Elapsed = Fresher;

         aTimer.Elapsed += new System.Timers.ElapsedEventHandler(Fresher);

//         aTimer.Elapsed = Fresher;


         //AddHandler aTimer.Elapsed,AddressOf Fresher;

         //AutoReset 属性为 true 时,每隔指定时间循环一次;   
         //如果为 false,则只执行一次。   
         aTimer.AutoReset = true;
         aTimer.Enabled = true;
                 
         //先给 Application("TimeStamp") 指定一个初值   
         Application.Lock();
         Application["TimeStamp"] = DateTime.Now.ToString();
         Application.UnLock();

      }

      protected void Fresher(Object sender,ElapsedEventArgs e)
      {   
         Application.Lock();  
         Application["TimeStamp"] = DateTime.Now.ToString(); 
         Application.UnLock();
      }

posted on 2004-06-20 13:58  奚彧  阅读(789)  评论(1)    收藏  举报