当 Quartz.NET/Quartz 发生什么时
...当下一个执行时间发生时作业仍在执行?
例如,如果我有一个每 30 秒发生一次的作业,并且 30 秒后它仍在运行,那么下一个实例会发挥作用还是会等待?
...when a job is still being executed when its next execution time occurs?
For example, if I have a job that occurs every 30 seconds, and after the 30 seconds it is still operating, would the next instance come into play or would it wait?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
简短的答案是,将执行一项新作业,除非您继承自 IStatefulJob,在这种情况下,一次只允许运行一个作业实例。
The short answer is that a new job will be executed, unless you are inheriting from IStatefulJob, in which case only one job instance is allowed to run at a time.
正如 TskTsk 回答的那样,您可以实现 IStatefulJob 而不是 IJob,但有一个问题!如果您的作业执行时间超过 30 秒(因此您有一个或多个作业正在等待该作业完成),则在其执行后,所有正在等待的作业将立即触发!为了克服这个问题,您需要创建实现 SimpleTrigger 的新类。这个新的触发器类应该重写 GetFireTimeAfter。
这样第一个作业完成后就不会立即执行下一个作业。
As TskTsk answered, you can implement IStatefulJob insted of IJob but there is a catch! If you are having job that is executing more than 30 seconds (thus you have on or more jobs waiting this one to finish), after its execution all jobs that were waiting will fire immidietly! To overcome this you need to create new class that implements SimpleTrigger. This new trigger class should have overriden GetFireTimeAfter.
This way the next job will not execute immidietly after first one is finished.