推荐一个C#任务调度库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/507247/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Recommend a C# Task Scheduling Library
提问by ssmith
I'm looking for a C# library, preferably open source, that will let me schedule tasks with a fair amount of flexibility. Specifically, I should be able to schedule things to run every N units of time as well as "Every weekday at XXXX time" or "Every Monday at XXXX time". More features than that would be nice, but not necessary. This is something I want to use in an Azure WorkerRole, which immediately rules out Windows Scheduled Tasks, "at", "Cron", and any third party app that requires installation and/or a GUI to operate. I'm looking for a library.
我正在寻找一个 C# 库,最好是开源的,它可以让我以相当大的灵活性安排任务。具体来说,我应该能够安排每 N 个时间单位以及“XXXX 时间的每个工作日”或“XXXX 时间的每个星期一”运行一次。更多的功能会很好,但不是必需的。这是我想在 Azure WorkerRole 中使用的东西,它立即排除了 Windows 计划任务、“at”、“Cron”以及任何需要安装和/或 GUI 才能操作的第三方应用程序。我在找图书馆。
采纳答案by Tiberiu Ana
http://quartznet.sourceforge.net/
http://quartznet.sourceforge.net/
"Quartz.NET is a port of very propular(sic!) open source Java job scheduling framework, Quartz."
“Quartz.NET 是非常流行的(原文如此!)开源 Java 作业调度框架 Quartz 的一个端口。”
PS: Word to the wise, don't try to just navigate to quartz.net when at work ;-)
PS:明智的话,不要试图在工作时导航到quartz.net ;-)
回答by Galwegian
See A New Task Scheduler Class Library for .NETon Codeproject.
请参阅Codeproject 上的.NET 的新任务调度程序类库。
回答by Tundey
I read about Quartzin this question How might I schedule a C# Windows Service to perform a task daily?. It's a C# library and allows for flexible scheduling.
我在这个问题中读到了Quartz如何安排 C# Windows 服务每天执行任务?. 它是一个 C# 库,允许灵活调度。
回答by RobS
Quartz seems like a nice solution.
Quartz 似乎是一个不错的解决方案。
I've recently (this year) had to write a custom task scheduler on a major project I was working on. They too could not use the Windows Task Scheduler, and also wanted the ability to execute custom functionality by virtue of uploading assemblies (via an ASP.net website) and have the service execute the appropriate task at the specified time.
我最近(今年)不得不为我正在从事的一个主要项目编写一个自定义任务调度程序。他们也无法使用 Windows 任务计划程序,并且还希望能够通过上传程序集(通过 ASP.net 网站)来执行自定义功能,并让服务在指定的时间执行适当的任务。
The thing was honestly a bit of a nightmare (not so much to design and implement, but the scheduling logic was a bit of a drag).
老实说,这有点像一场噩梦(设计和实现并不多,但调度逻辑有点拖沓)。
I'd highly recommend exhausting all other avenues before deciding to "roll your own" (a.k.a reinvent the wheel!).
我强烈建议在决定“自己动手”(又名重新发明轮子!)之前用尽所有其他途径。
回答by MikeD
I used Quartz back in my Java days and it worked great. I am now using it for some .Net work and it works even better (of course there are a number of years in there for it to have stabalized). So I certainly second the recommendations for it.
我在 Java 时代使用过 Quartz,它工作得很好。我现在将它用于一些 .Net 工作,它的效果更好(当然,它已经稳定了很多年)。所以我当然支持它的建议。
Another interesting thing you should look at, that I have just begun to play with is the new System.Threading.Tasks in .Net 4.0. I've just been using the tasks for parallelizing work and it takes great advantage of multi cores/processors. I noticed that there is a class in there named TaskScheduler, I haven't looked at it in detail, but it has methods like QueueTask, DeQueTask, etc. Might be worth some investigation at least.
你应该看看的另一件有趣的事情,我刚刚开始玩的是 .Net 4.0 中的新 System.Threading.Tasks。我刚刚使用任务来并行化工作,它充分利用了多核/处理器的优势。我注意到那里有一个名为TaskScheduler的类,我没有详细研究它,但它有QueueTask、DeQueTask等方法。至少值得研究一下。
回答by Naveen Vijay
There is a new cloud based scheduler from Aditi Technologiescalled Scheduler.
Aditi Technologies有一个新的基于云的调度程序,称为Scheduler。
Scheduler allows developers to schedule the execution of tasks through HTTP webhooks that run on simple or complex CRON schedules.
Scheduler 允许开发人员通过运行在简单或复杂 CRON 计划上的 HTTP webhook 来安排任务的执行。