I need to run job on 2 different schedules (morning and afternoon). I know how to run it on one schedule, but not sure how to set it so 2 schedules trigger this job
var saferWatchJobDetail = JobBuilder.Create<SaferWatchProcessor>().Build();
var swtriggerMorning = TriggerBuilder.Create().WithCronSchedule("0 10 6 ? * MON-SUN *", cs => cs.InTimeZone(TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time"))).Build();
var swtriggerAfternoon = TriggerBuilder.Create().WithCronSchedule("0 10 13 ? * MON-FRI *", cs => cs.InTimeZone(TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time"))).Build();
this.scheduler.ScheduleJob(saferWatchJobDetail, swtriggerMorning);
According to documentation it seems like I need to use ScheduleJob
override with ISet<ITrigger>
but I'm not sure about 2 things:
- What is implementing
ISet
and how do I instantiate this object? - What is other parameter
replace
? Not sure how should I use it. And what is the "key"? From documentation:
If any of the given job or triggers already exist (or more specifically, if the keys are not unique) and the replace parameter is not set to true then an exception will be thrown.