简体   繁体   English

删除Quartz.net中的作业触发器

[英]Delete trigger for job in Quartz.net

How do I delete a trigger for a job in Quartz.net and keep the job? 如何在Quartz.net中删除作业的触发器并保留作业? This is only an issue when deleting the last trigger on the job, right now it deletes the job as well. 这只是在删除作业上的最后一个触发器时的问题,现在它也会删除该作业。

The code I am using is: 我使用的代码是:

_scheduler.UnscheduleJob(trigger.Key);

and that works fine as long as the job for that triggers has more than one trigger. 只要该触发器的作业具有多个触发器,该工作正常。 If this is the last trigger the job is also deleted, and that is something I don't want. 如果这是最后一次触发,则作业也会被删除,这是我不想要的。

When you create your job you have to specify that you want it to stick around after all triggers have been deleted, which you do by calling StoreDurably() 在创建作业时,您必须指定在删除所有触发器后保留它,这可以通过调用StoreDurably()来实现。

eg 例如

 IJobDetail job = JobBuilder.Create<HelloJob>()
        .WithIdentity("job1", "group1")
        .StoreDurably()
        .Build();

You can also use 你也可以使用

// Unschedule a particular trigger from the job (a job may have more than one trigger)
scheduler.UnscheduleJob(new TriggerKey("trigger1", "group1"));

Note that my syntax is slightly different than the Quartz.net reference 请注意,我的语法与Quartz.net参考略有不同

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM