简体   繁体   English

自定义TaskScheduler通过DateTime启动任务

[英]Custom TaskScheduler to start task by DateTime

I´m currently investigating the namespace System.Threading.Tasks and the abstract base class TaskScheduler . 我目前正在研究名称空间System.Threading.Tasks和抽象基类TaskScheduler I also found the ParallelExtensionsExtra with some custom schedulers inherited from TaskScheduler. 我还发现了ParallelExtensionsExtra ,其中包含一些自TaskScheduler继承的自定义调度程序。

But i need a TaskScheduler that allows me to specify a DateTime, when to execute a task. 但是我需要一个TaskScheduler,它允许我指定DateTime以及何时执行任务。 Can anybody provide such a class or found it anywhere on the internet and share a link. 任何人都可以提供这样的课程或在互联网上的任何地方找到它并共享链接。

If not how could i implement such a TaskScheduler on my own (with TaskScheduler as base class)? 如果没有,我如何自己实现这样的TaskScheduler(以TaskScheduler作为基类)?

System.Threading.Task.TaskScheduler is part of parallel library introduced with .NET 4 - its about executing tasks concurrently (parallel). System.Threading.Task.TaskScheduler是.NET 4引入的并行库的一部分-关于并行执行任务(并行)。 The scheduling is related to scheduling work on threads/cores rather than over some time horizon/period. 调度与在线程/核心上调度工作有关,而不是与某个时间范围/期间有关。 Are you sure this is what you are looking for? 您确定这是您想要的吗?

Windows have scheduled tasks that allows you to schedule some work on specific date/time and/or with specific periodicity/frequency. Windows具有计划的任务,使您可以按特定的日期/时间和/或按特定的周期/频率安排一些工作。 See this article that provides wrapper in .NET to use this functionality. 请参阅这篇文章 ,在.NET提供的包装使用此功能。 Perhaps this will fit your requirement. 也许这将满足您的要求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM