如题,要是用timmer是不是不能用在B/S模型里? 并求教timmer的用法

解决方案 »

  1.   

    我实践了 在网上找了一个 不好用protected void Application_Start(Object sender, EventArgs e)
        {
            System.Timers.Timer t = new System.Timers.Timer(1000 * 5);//每10秒触发一次   
            t.AutoReset = true;
            t.Enabled = true;
            t.Elapsed += new System.Timers.ElapsedEventHandler(yourFun);
        }    private void yourFun(object sender, System.Timers.ElapsedEventArgs e)
        {
            string sql = "select max_lvl from jobs where job_id=13";
            DataSet ds = DB.DbHelper.Query(sql);
            this.Response.Write(ds.Tables[0].Rows[0]["max_lvl"].ToString());
        }   
      

  2.   

    Timer,只能在用户打开网页的情况下有效而已。如果你想做到任何时候都可以触发,你写个windows服务呗。
      

  3.   

    你start了没有?
    在第一个方法最后加一个
    t.Start();试试
      

  4.   

    B/S没试过Timer,C/S里Timer还是很好用的
    想停就stop,想开就start..
      

  5.   

    查询时间是否有损耗
    减少数据的检索量,例如索引、SQL语句
    客户端轮询服务器