c# 定时任务

来源:互联网 发布:软件稳定性测试方法 编辑:程序博客网 时间:2024/04/30 13:15
protected void Application_Start()
        {
            //定时任务  定时更新项目状态,招募时间到期的项目修改其状态
            System.Timers.Timer t = new System.Timers.Timer(84600000);//设置间隔时间 毫秒秒 84600000秒=一天
            t.Enabled = true;//允许timers执行
            t.Elapsed += new System.Timers.ElapsedEventHandler(ChangeProjectState);//定义回调
            t.AutoReset = true;//多次循环
            AreaRegistration.RegisterAllAreas();


            RegisterRoutes(RouteTable.Routes);
        }


        //定时任务,24小时执行一次
        public void ChangeProjectState(object source, System.Timers.ElapsedEventArgs e)
        {
           //循环方法体

}

//注意asp.net MVC 项目  循环放在global.asax文件中

0 0
原创粉丝点击