主攻ASP.NET.3.5.MVC3.0架构之重生:MVC在Global.asax.定义定时处理程序

        protected void Application_Start()

        {

            AreaRegistration.RegisterAllAreas();



            RegisterRoutes(RouteTable.Routes);

            //RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);



            ///这里是定义定时处理程序,时间1秒钟,可以讲1000改大一些

            int time = ((1000 * 60) * 60) * 10;

            //int time = 1000;

            System.Timers.Timer aibidTimer = new System.Timers.Timer(time);

            aibidTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);

            aibidTimer.Interval = time;

            aibidTimer.Enabled = true;

            aibidTimer.AutoReset = true;



        }

        ArticleCategoryRepository categoryrepository = new ArticleCategoryRepository();

        private void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e)

        {



            ///这里定义要处理的逻辑

            

        }

Global.asax.cs
 

你可能感兴趣的:(asp.net)