私が達成しようとしていること: 私は 5 秒ごとに起動する 2 番目のトリガーと、5 秒以上 (たとえば 7) かかることもあるステートフルなジョブを持っています。
start: 00:00:00
end : 00:00:07
start: 00:00:07 < right after previous has finished
私が欲しいもの:
start: 00:00:00
it should run at 00:00:05 but it hasn't
end : 00:00:07
start: 00:00:10 (5 seconds after previous, successive or not)
Quartz.net バージョン 2 と 1 を試しました。
ジョブ:
[PersistJobDataAfterExecution]
[DisallowConcurrentExecution]
public class StatefulJob : IJob (or IStatefulJob in 1.x version)
{
public void Execute(IJobExecutionContext context)
{
Console.WriteLine("StateFull START " + DateTime.Now.ToString());
Thread.Sleep(7000);
Console.WriteLine("StateFull END " + DateTime.Now.ToString());
}
}
引き金:
var trigger1 = TriggerBuilder
.Create()
.WithSimpleSchedule(x =>
x.WithIntervalInSeconds(timeout)
.RepeatForever()
.Build();
編集
を使用しようとしましWithMisfireHandlingInstructionIgnoreMisfires()
たが、スケジューラがシャットダウンされているか、使用可能なスレッドがないためにミスファイアが発生します。私の場合、StatefulJob を使用しているためジョブが実行されません。多分私は間違っているかもしれませんが、動作は同じままです。
EDIT2 OK、「実行中」フラグを使用したソリューションは、シングルスレッドアプリで完璧に機能します。しかし、このジョブをいくつかのスレッドで (異なるパラメータで) 実行すると機能しません。