0

Hi I would like to schedule a Task which will be executed every 1 hour.

But the time consumed by the Task is somewhat "random" which means that it may take 30 minutes or it may also take 1h15min. Only one Task at a time must run.

I would like to be able to execute the Task and if the interval time elapsed it will run the Task directly, if the time not elapsed it will wait till the 1 hour complete.

What is the best way to do this?

I started to look at FluentScheduler but it does not allow me to configure a schedule with the scenario i described.

4

1 回答 1

0

感谢您的有用评论,我将探索 Quartz.NET,它似乎是一个强大的调度程序。

我设法做了一个小的(一项工作)“调度程序”,在每个任务之间每隔一小时运行一次。

我正在使用 TPL.Dataflow,这是我的代码

TransformBlock<int, int> block = new TransformBlock<int, int>(i =>
{
    //Thread.Sleep(5000);
    DoSomething();
return i + 1;
});

block.LinkTo(block);
block.Post(0);

我知道这是非常脆弱的,但它会完成这项工作。感谢您的评论!我会探索更多的可能性。

于 2013-10-19T20:05:05.720 回答