具有新触发器集的Quartz.NET重新计划作业 [英] Quartz.NET Rescheduling job with new trigger set

查看:82
本文介绍了具有新触发器集的Quartz.NET重新计划作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Quartz作业,该作业计划有一组触发器,执行时间为3到5分钟.但是在将来的任何时候(可能是一周后或几分钟后),我可能都需要使用新的触发器集重新安排它的时间.触发器集上会有一些添加或删除.

I have a Quartz job which is scheduled with a collection of triggers and it has 3 to 5 minutes of execution time. But at any moment in the future(it may be a week later or a couple of minutes later) I may need to reschedule it with a new trigger set. There will be some additions or deletions on trigger set.

如何使用新的触发器集重新计划作业?这里的窍门是,我想确保当时没有工作实例存活,因此我可以可靠地重新计划我的工作.感谢您的帮助...

How can I reschedule the job with new trigger set? The trick here is, I want to be sure that no instance of the job is alive at that moment, so I can reschedule my job reliably. Thanks for any help...

推荐答案

据我所知,您可以执行以下操作:

As I remember it, you can do:

List<JobExecutionContext> context = scheduler.GetCurrentlyExecutingJobs()

遍历列表,并调用GetJobInstance()(或类似方法)以查找为其创建上下文的作业,然后检查它是否是您感兴趣的作业.如果不是,则可以使用相同的触发器重新计划.尝试这样的事情:

Iterate the list and call GetJobInstance() (or something similar) to find the job the context was created for, then check if it's the job you're interested in. If not, you can reschedule using the same trigger. Try something like this:

Trigger trigger = Global.scheduler.GetTrigger("testTrigger","triggerGroup");

trigger.set(); 

Global.scheduler.RescheduleJob(trigger.JobName, trigger.JobGroup, trigger);

这篇关于具有新触发器集的Quartz.NET重新计划作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆