Quartz.NET设置MisfireInstruction

编程入门 行业动态 更新时间:2024-10-28 12:17:52
本文介绍了Quartz.NET设置MisfireInstruction的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用Quartz.NET在C#中工作,并且在CronTrigger上设置失火指令时遇到问题.我正在运行安装了Quartz DB的SQL后端.我有以下代码可以很好地用于创建作业和运行计划程序.

I'm working in C# using Quartz.NET and am having problems setting the misfire instruction on a CronTrigger. I'm running an SQL backend with the Quartz DB installed. I have the following code which works fine for creating a job and running a scheduler.

IScheduler _scheduler; IJobDetail job; ISchedulerFactory sFactory; ICronTrigger trig; sFactory = new StdSchedulerFactory(); _scheduler = sFactory.GetScheduler(); _scheduler.Start(); job = JobBuilder.Create<Test>().WithIdentity("testJob", "testGroup").Build(); trig = (ICronTrigger) TriggerBuilder.Create().WithIdentity("testTrigger", "testGroup").WithCronSchedule("0/10 * * * * ?").Build(); int i = trig.MisfireInstruction; _scheduler.ScheduleJob(job, trig);

我唯一可以访问的误启动指令是trig.MisfireInstruction,它是一个整数,我无法设置它. 在CronScheduleBuilder中,还有WithMisfireHandlingInstruction开头的一些函数.

The only misfireinstruction I can access is trig.MisfireInstruction which is an int, and I can't set it. There are also some functions beginning WithMisfireHandlingInstruction in CronScheduleBuilder.

推荐答案

您的触发器创建应如下所示:

Your trigger creation should be like this:

trig = (ICronTrigger)TriggerBuilder .Create() .WithIdentity("testTrigger", "testGroup") .WithCronSchedule("0/10 * * * * ?", x => x.WithMisfireHandlingInstructionFireAndProceed()) .Build();

您可以使用以下选项:

  • WithMisfireHandlingInstructionDoNothing
  • WithMisfireHandlingInstructionFireAndProceed
  • WithMisfireHandlingInstructionIgnoreMisfires

您可以在此处找到很好的解释.

You can find a good explanation here.

更多推荐

Quartz.NET设置MisfireInstruction

本文发布于:2023-11-05 21:09:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1561866.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Quartz   NET   MisfireInstruction

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!