程序中中,我想每天晚上执行一个回收数据的事件,请问怎么实现。
(定时执行回收数据的方法(比如23:00))

解决方案 »

  1.   

    timer定时检测当前时间
    或者用windows的计划任务
      

  2.   

    如果回收数据的事件可以和程序分离,就用windows的任务计划。
    如果无法分离,就用Quartz.net任务调度框架。
    还可以自己搞定,用timer,定时检测时间,
      

  3.   

    启用SQL Server 代理,新建sql作业,定时每天23:00执行该作业(你要做的事情:一段数据库维护代码)
      

  4.   

    写个windows服务呗,类似的例子
      

  5.   


    感觉这个比较好Quartz.net任务调度框架。
      

  6.   

    http://blog.csdn.net/jinlong5200/article/details/3182451  这个比较好
      

  7.   

    定时任务 Windows Service
      

  8.   


    oracle 应该有JOB吧?
    http://space.itpub.net/27157/viewspace-425567
      

  9.   

    数据库里面的作业 也可以在代码里面处理。。Global里面定义一个timmer在Application_start里面对timer进行处理 System.Timers.Timer timer; 
     protected void Application_Start()
            {
                AreaRegistration.RegisterAllAreas();            RegisterGlobalFilters(GlobalFilters.Filters);
                RegisterRoutes(RouteTable.Routes);            timer = new System.Timers.Timer(1000*60*5);//5分钟
                timer.Elapsed += new System.Timers.ElapsedEventHandler(Auto_Run);
                timer.Start(); 
            }        void Auto_Run(object sender, System.Timers.ElapsedEventArgs e)
            {
                PerformanceController controller = new PerformanceController();            controller.AutoRun();
               
            }
      

  10.   

    这个写个windows服务比较好:    public partial class MyServer : ServiceBase
        {
            public MyServer()
            {
                InitializeComponent();
                this.ServiceName = "MyServer";
            }
            Thread th = null;
            bool isStop = false;
            protected override void OnStart(string[] args)
            {
                if (th == null)
                {
                    th = new Thread(new ThreadStart(delegate
                    {
                        while (!isStop)
                        {
                            //上午10点和下午4点
                            if ((DateTime.Now.Hour == 10 || DateTime.Now.Hour == 16) && DateTime.Now.Minute == 0)
                            {
                               //执行你的任务
                            }
                            Thread.Sleep(60000);
                        }                }));
                }
                th.Start();
            }        protected override void OnStop()
            {            isStop = true;
                Thread.Sleep(3000);
                if (th != null)
                {
                    th.Abort();
                    th = null;
                }
            }
            protected override void OnPause()
            {
            }
            protected override void OnContinue()
            {
            }
            
        }
      

  11.   

    Timer定时器,右下角托盘,再放入系统启动项。我当年有个程序就是这么做的,实际情况很不错。
      

  12.   

    起哦已经用quartz.net实现了,感觉用quartz.net有些大材小用了,呵呵 谢谢各位!