运行周期性任务 [英] Running periodic tasks
问题描述
- ASP.NET 4.51的WebForms,VS2013
在我希望它定期唤醒并运行一些或其他任务的应用程序。我猜测,这将在应用程序内和ASPX页面执行的实际工作调用特定的URL来完成。
Within the application I want it to wake up periodically and run some or other tasks. I am guessing that this would be done by calling a particular URL within the application and that ASPX page does the actual work.
我的问题是我怎么触发这个?我所寻找的是类似的意思是由WevForms应用援引cron作业定期。
My question is how do I trigger this? What I am looking for is something to a cron job that is "invoked" by the WevForms application periodically.
推荐答案
您所描述的是什么样的初始不错的办法ASP的任何新的开发者的声音。网络问自己(很好,至少我们许多人在某些时候做的)。我建议在这个时间投资之前,你重新评估你的策略。
What you are describing sounds like the initial bad approach any new developer on ASP. Net asks himself (well, at least many of us do at some point). I would recommend you re-evaluate your strategy before investing time on this.
不过,你应该选择继续通过此路径,这个Timer类会完成这项工作。用它上的应用程序启动方法您的Global.asax.cs文件。
Nevertheless, should you choose to continue through this path, this Timer class will get the job done. Use it on your Global.asax.cs file on the Application start method.
的http:// MSDN .microsoft.com / EN-US /库/ system.timers.timer(v = vs.110)的.aspx
不要忘了停在应用程序停止方法计时器了。
Don't forget to stop the timer on the application stop method too.
这篇关于运行周期性任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!