I have executed 2 jobs (MyJob1
and MyJob2
) as below:
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!");
}
--> I have tried to use _jobManager
.Stop() but it stops all my job, so how to stop or pause only MyJob2
?
Use Scheduler.PauseJob
like this:
var scheduler = StdSchedulerFactory.GetDefaultScheduler();
scheduler.PauseJob(new JobKey("Job2Identity", "MyGroup"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With