I have a scheduler task that runs regularly (once a minute). I run this task using the following snippet:
Scheduler = await StdSchedulerFactory.GetDefaultScheduler().ConfigureAwait(false);
await Scheduler.Start().ConfigureAwait(false);
JobDetail = JobBuilder.Create<SchedulerJob>().Build();
Trigger = TriggerBuilder.Create().StartNow().WithPriority(1).WithCronSchedule(cronExpression).Build();
await Scheduler.ScheduleJob(JobDetail, Trigger).ConfigureAwait(false);
What I want/need to do now is to schedule a second separate task that is not concurrent. This means the second, new task has priority, always running when both are called simultanuously and the first task either waiting or not executing.
Both Classes (SchedulerJob and the new Class) are marked as [DisallowConcurrentExecution], but they still both run at the same time.
I also tried two alternatives with JobDataMap:
- Reuse JobDetail, use with different JobDataMap -> Problem is that scheduler does not allow scheduling the same JobDetail again with a different map.
- Make new JobDetail with the same class, with different JobDataMap, on the same class -> Problem is that they are still executed at the same time, [DisallowConcurrentExecution] has no effect
Is there a built-in way with Quartz to have two separate JobDetails/Job Classes be non-concurrent? I wanted to avoid having to implement non-concurrency checks manually.