我已经执行了以下两个任务(MyJob1
和 MyJob2
):
public async Task < ActionResult > ScheduleJob() {
await _jobManager.ScheduleAsync < MyJob1 > (
job => {
job.WithIdentity("Job1Identity", "MyGroup")
.WithDescription("This is job 1");
},
trigger => {
trigger.StartNow()
.WithSimpleSchedule(schedule => {
schedule.RepeatForever()
.WithIntervalInSeconds(5)
.Build();
});
});
await _jobManager.ScheduleAsync < MyJob2 > (
job => {
job.WithIdentity("Job2Identity", "MyGroup")
.WithDescription("This is job 2");
},
trigger => {
trigger.StartNow()
.WithSimpleSchedule(schedule => {
schedule.RepeatForever()
.WithIntervalInSeconds(5)
.Build();
});
});
return Content("OK, scheduled!");
}
--> 我尝试使用 _jobManager
.Stop() 但它会停止所有的工作,那么如何只停止或暂停 MyJob2
?