定时执行事件 程序中中,我想每天晚上执行一个回收数据的事件,请问怎么实现。(定时执行回收数据的方法(比如23:00)) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 timer定时检测当前时间或者用windows的计划任务 如果回收数据的事件可以和程序分离,就用windows的任务计划。如果无法分离,就用Quartz.net任务调度框架。还可以自己搞定,用timer,定时检测时间, 启用SQL Server 代理,新建sql作业,定时每天23:00执行该作业(你要做的事情:一段数据库维护代码) 写个windows服务呗,类似的例子 感觉这个比较好Quartz.net任务调度框架。 http://blog.csdn.net/jinlong5200/article/details/3182451 这个比较好 定时任务 Windows Service oracle 应该有JOB吧?http://space.itpub.net/27157/viewspace-425567 数据库里面的作业 也可以在代码里面处理。。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(); } 这个写个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() { } } Timer定时器,右下角托盘,再放入系统启动项。我当年有个程序就是这么做的,实际情况很不错。 起哦已经用quartz.net实现了,感觉用quartz.net有些大材小用了,呵呵 谢谢各位! 小问题请教 拜求如何数据库里读取拍摄种类排行 如何动态设置RadioButtonList的RepeatDirection属性 我想做个分页功能,但如何简单快速地知道文章总数呢? 怎么样上传一个目录下的所有文件到服务器 请教高手:索引超出范围。必须为非负值并小于集合大小。参数名:index (在线等) 我的vs.net 2003大不开asp.net的项目原代码???求救 求一函數 请问如何在Page_Load中得到当前引起回发的是哪个控件? 有那为朋友能帮帮我,我们在写一本asp.net的书,那为朋友能帮我联系一下出版社。 aspx页面文件中,头部Inherits属性的作用是什么啊 排序问题
或者用windows的计划任务
如果无法分离,就用Quartz.net任务调度框架。
还可以自己搞定,用timer,定时检测时间,
感觉这个比较好Quartz.net任务调度框架。
oracle 应该有JOB吧?
http://space.itpub.net/27157/viewspace-425567
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();
}
{
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()
{
}
}