【问题标题】:Class annotation 'DisallowConcurrentExecution' in Quartz.net doesn't workClass annotation \'DisallowConcurrentExecution\' in Quartz.net doesn\'t work
【发布时间】:2022-12-27 18:50:07
【问题描述】:
I've got a Job class with method, that get the data from the DB and save the latest data to the static field.
But it gets data very often, so the problem could be with delays, that the previous job won't finish before the timer would run the next job.
So I used annotation [DisallowConcurrentExecution], but it seems to do completely nothing.
How can I use this DisallowConcurrentExecution in the other way?
【问题讨论】:
标签:
c#
.net
repeat
quartz.net
【解决方案1】:
Just add this keyword in your Module in which you're creating this service at the startup.
j.DisallowConcurrentExecution();
services.AddQuartz(
cfg =>
{
cfg.UseMicrosoftDependencyInjectionJobFactory();
cfg.ScheduleJob<YourJobClass>(
t => t.WithSchedule(SimpleScheduleBuilder.RepeatMinutelyForever(1)),
j =>
{
j.WithIdentity(typeof(YourJobClass).FullName!).WithDescription("My job");
j.DisallowConcurrentExecution();
});