Quartz.net 在作业完成后每隔一定时间重复作业
我目前正在一个简单的应用程序中实现 Quartz.net,该应用程序应该每(例如)5 秒执行一段代码。只是现在代码有时需要 5 秒以上才能完成。
起初,我遇到了代码在相同代码仍在运行时执行的问题,我通过使用 IStateFulJob 接口而不是 IJob 接口解决了这个问题。
但我真正想要完成的是,我的作业在作业完成后 5 秒执行,而不是在上一个作业开始后 5 秒执行。
我当然可以处理当我的侦听器“听到”作业已准备好并重新安排作业时触发的事件,但我想知道是否没有任何标准功能。
I am currently implementing Quartz.net in a simple application that should execute a piece of code every (for example) 5 seconds. Only now the code sometimes takes more than 5 seconds to complete.
At first I had the problem that the code was executed while the same code was still running, I fixed this by using the IStateFulJob interface instead of the IJob interface.
But what I would really like to accomplish is, that my job is executed 5 seconds AFTER the job is completed, not 5 seconds after my previous job is started.
I ofcourse could handle the event which is triggered when my listener 'hears' that the job is ready and re-schedule the job, but I was wondering if there isn't any standard functionality for this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
目前还没有标准的方法来实现这一点,因为 Quartz.NET 的想法是预定义(预先计算)的触发时间并轮询正确的时间来触发工作。
您描述的方式将是最简单的路径。从作业安排下一次执行或从侦听器安排。
Currently there is no standard way to achieve this as Quartz.NET plays on the idea to have a predefined (calculated beforehand) fire time and polling for right time to trigger the work.
The way you described would be the easiest path. Either schedule from the the job the next execution or from the listener.