[英]Mimic Windows Task Scheduler with code
I'm looking for a way to make a program that runs itself (or a method) every X time (days, weeks, whatever). 我正在寻找一种方法来制作一个每X次(几天,几周,等等)运行自己(或方法)的程序。 Basically, I want my program to do what the Windows Task Scheduler could do.
基本上,我希望我的程序能够执行Windows任务计划程序可以执行的操作。 The reason I don't use the Task Scheduler is because I plan to deploy this application on a server which I have no remote access to, but need to re-generate some files every given time.
我不使用任务计划程序的原因是因为我打算在没有远程访问权限的服务器上部署此应用程序,但需要在每个给定时间重新生成一些文件。
Suggestions? 建议?
You could use Quarts.net: 你可以使用Quarts.net:
http://quartznet.sourceforge.net/ http://quartznet.sourceforge.net/
You can just run a program as a service, it can have a Timer
that is executed on the schedule you need. 您可以将程序作为服务运行,它可以有一个按您需要的计划执行的
Timer
。 Topshelf is a simple service host for .NET that could you generate that service. Topshelf是一个简单的.NET服务主机,可以生成该服务。 I think the sample service provided does just that at a small interval.
我认为提供的样本服务只是在很短的时间间隔内完成。
Create a Windows Service and use a timer. 创建Windows服务并使用计时器。 You can pick between System.Timers.Timer and System.Threading.Timer based on the differences you can find here:
您可以根据您在此处找到的差异在System.Timers.Timer和System.Threading.Timer之间进行选择:
http://www.intellitechture.com/System-Windows-Forms-Timer-vs-System-Threading-Timer-vs-System-Timers-Timer/ http://www.intellitechture.com/System-Windows-Forms-Timer-vs-System-Threading-Timer-vs-System-Timers-Timer/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.