I have the following code:
IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();
scheduler.Start();
IJobDetail job = Job
Add the Job to the Scheduler.
Then on the creation of the triggers, use ForJob
.
The code below is tested.
IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();
//// scheduler.DeleteJob(new JobKey("J_Email"));
IJobDetail job = JobBuilder.Create<MyConcreteJob>().StoreDurably().WithIdentity("J_Email", "J_Mailing").Build();
scheduler.AddJob(job, true /* bool replace */ ); /* Add the given IJob to the Scheduler - with no associated ITrigger. */
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("MailTrigger1", "T_Mail1")
.StartNow()
.WithSimpleSchedule(x => x.WithMisfireHandlingInstructionIgnoreMisfires()
.WithIntervalInSeconds(3)
.RepeatForever())
.ForJob(job)
.Build();
ITrigger triggernew = TriggerBuilder.Create()
.WithIdentity("MailTrigger", "T_Mail")
.StartNow()
.WithSimpleSchedule(x => x.WithMisfireHandlingInstructionIgnoreMisfires()
.WithIntervalInSeconds(5)
.RepeatForever())
.ForJob(job)
.Build();
scheduler.ScheduleJob(triggernew);
scheduler.ScheduleJob(trigger);
scheduler.Start();