How to make a trigger wait for the end to start Quartz C # again

I am using Quartz 2.5.0.0

And I have the following code to run whatever job I want. All my work is in the folder, since I just take it there.

var scheduler = StdSchedulerFactory.GetDefaultScheduler();
scheduler.Start();

var t = new ImportingLib.Importer();
t.DoImport();

foreach (var component in t.CallAllComponents())
{   
    var job = JobBuilder.Create(component)
        .WithIdentity(component.Name)
        .Build();

    var trigger = TriggerBuilder.Create()
   .WithIdentity($"{component.Name}Trigger")
   .StartNow()
   .WithSimpleSchedule(x => x
       .WithIntervalInSeconds(10)
       .RepeatForever())
   .ForJob(component.Name)
   .Build();
    scheduler.ScheduleJob(job, trigger);
}

      

I want this job to be done every 10 seconds, but I need to wait for it to finish, right after that, run the same Job again. A way to learn how to work with protectors, but I haven't found how to do it. Any idea how I can get it to work?

+3


source to share


1 answer


I haven't worked with Quartz.NET

in a while, but I'll try:

  • Decorate the assignment class with the attribute [DisallowConcurrentExecution]

  • Fire work twice. Quartz needs to make sure the assignments don't work on top of each other.


More information here

+1


source







All Articles