现在的位置: 首页 > 综合 > 正文

asp.net 定时器的使用

2012年08月31日 ⁄ 综合 ⁄ 共 352字 ⁄ 字号 评论关闭

在global.asax 中使用.

Timer timer;

    Timer timerUrl;

    void Application_Start(object sender, EventArgs e)
    {

        TimerCallback callBack2 = new TimerCallback(Test2);
        timerUrl = new Timer(callBack2, sender, 1000, 1000);
    }

    private void Test2(Object state)
    {
        // 定时操作写到这里
       }

 

    void Application_End(object sender, EventArgs e)
    {
        timerUrl.Dispose();
    }

抱歉!评论已关闭.