Quartz.NET触发器:在指定的时间间隔运行一次
我在 Windows 服务中使用 Quartz.NET 库来运行日常工作等。我正在使用 AdoJobStore。基本上,我希望我的工作能够在午夜到凌晨 1 点之间的任何时间执行一次。因此,如果服务在午夜停止并且有人在 00:30 启动它,我希望该作业在那时执行(仅一次),但如果服务在凌晨 2 点启动,我不希望该作业在当天执行。
如何将触发器配置为在指定时间间隔内仅运行一次?
I'm using the Quartz.NET library in a Windows service to run a daily job among others. I'm using AdoJobStore. Basically I want my job to be executed once any time between midnight and 1AM for example. So if the service was stopped at midnight and someone starts it at 00:30 I want the job to be executed then (only once) but if the service is started at 2AM I don't want the job to be executed that day.
How can a trigger be configured to run only once in a specified interval?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来您需要自定义“失火”行为。来自 Quartz 文档:
不幸的是,您需要的行为不受开箱即用的支持。您需要将作业安排在午夜精确执行,然后实现自定义失火。应该可以使用
ITriggerListener.TriggerMisfired
。It looks like you need a custom 'misfire' behavior. From Quartz docs:
Unfortunately the behavior that you need is not supported out of the box. You would need to schedule your job to execute exactly at midnight and then implement custom misfire. It should be possible to use
ITriggerListener.TriggerMisfired
.