我想做的是 新消息提示  这样可以吗??  
void Application_Start(object sender, EventArgs e) 
    {
         
        // 在应用程序启动时运行的代码
        System.Timers.Timer t = new System.Timers.Timer(1000 * 10);//每10秒触发一次
        t.AutoReset = true;
        t.Enabled = true;
        t.Elapsed += new System.Timers.ElapsedEventHandler(Fun);
    }   
    private void Fun(object sender, System.Timers.ElapsedEventArgs e)
    {
        //这里是访问数据库的代码
        string where = "TestState = 0";
        ZCGLModel.f_Test_List list = ZCGLBLL.f_Test.Select_f_TestByTestState1(where);
       
            if (ZCGLBLL.f_Test.GetCount(where) > 0)
            {             //提示信息
              
            }             
    }

解决方案 »

  1.   

    Application_Start是整个应用程序的开始。提示给用户的信息,不能放在这里。
      

  2.   

    如果你用sql2005以上的数据库,那么可以使用SqlDependency.OnChange事件
    使用方法http://www.cnblogs.com/yjmyzz/archive/2009/06/14/1502921.html你也可以写个提醒的方法编译成DLL文件 然后通过数据库里写的触发器来调用自定义的CLR函数,通过CLR函数调用这个DLL文件里面写的提醒方法,进行提醒!
      

  3.   

    看看这个是不是你需要的Ajax Timer.参考:
    ASP.NET AJAX入门系列(10):Timer控件简单使用
    http://www.cnblogs.com/Terrylee/archive/2006/11/14/Introduction_to_the_Timer_Control.html
      

  4.   

    1提示信息的地方不要阻塞线程(不要用messageBox)
    2要和UI一个线程
    3select 超过10秒时 timer tick 会累积
      

  5.   


    Web上基本没法实现Push,因此得用轮询,也就是用页面上用ajax Timer,定时检查,如果有更新,提示用户。
      

  6.   

    Web有服务器推,
    还有基于html5的websocket
      

  7.   

    http://www.cnblogs.com/Terrylee/archive/2006/11/14/Introduction_to_the_Timer_Control.html 
      

  8.   

    还是这样主动PUSH比较好,避免无谓的数据访问
      

  9.   

    最简单 Ajax轮询<body>
        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:Timer ID="Timer1" runat="server" Interval="1000" ontick="Timer1_Tick" />
                    <span id="clock"  runat="server"></span>
                </ContentTemplate>
            </asp:UpdatePanel> 
        </form>
    </body> protected void Timer1_Tick(object sender, EventArgs e)
    {
        clock.InnerText=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
    }