[DisallowConcurrentExecution]
public class MyJob : IJob
{
public void Execute(IJobExecutionContext context)
{
Console.WriteLine(context.ScheduledFireTimeUtc.Value);
Thread.Sleep(5000);
}
}
class Program
{
static void Main(string[] args)
{
var schedulerFactory = new StdSchedulerFactory();
var scheduler = schedulerFactory.GetScheduler();
var trigger = TriggerBuilder.Create()
.WithSimpleSchedule(s => s
.WithIntervalInSeconds(1)
.WithMisfireHandlingInstructionIgnoreMisfires()
.RepeatForever());
var job = JobBuilder.Create<MyJob>();
scheduler.ScheduleJob(job.Build(), trigger.Build());
scheduler.Start();
Console.ReadLine();
}
}
This is the result when it runs
2014-04-10 22:48:40 +00:00
2014-04-10 22:48:41 +00:00
2014-04-10 22:48:42 +00:00
2014-04-10 22:48:43 +00:00
This means that the jobs queue up. How to modify this code so that when job is not able to run it is indeed ignored and not queued up for execution?