您可以使用 StartNow 为您的作业添加第二个触发器。假设您有一个名为 SomeJob 的工作类,我认为这对您有用。
var schedulerFactory = new StdSchedulerFactory();
var scheduler = schedulerFactory.GetScheduler();
scheduler.Start();
IJobDetail job = JobBuilder.Create<SomeJob>()
.WithIdentity("job1", SchedulerConstants.QI_GROUP)
.Build();
Trigger trigger = newTrigger()
.withIdentity(SchedulerConstants.TRIGGER_CLARITY,SchedulerConstants.QI_GROUP)
.withSchedule(cronSchedule("0 0/60 * * * ?").withMisfireHandlingInstructionDoNothing())
.build();
scheduler.ScheduleJob(job, trigger);
IJobDetail job2 = JobBuilder.Create<SomeJob>()
.WithIdentity("job2", SchedulerConstants.QI_GROUP)
.Build();
Trigger trigger2 = newTrigger()
.withIdentity("trigger2",SchedulerConstants.QI_GROUP)
.StartNow()
.build();
scheduler.ScheduleJob(job2, trigger2);