gpt4 book ai didi

c# - 为什么 Quarz.net 作业会为同一个触发器实例多次触发 C#

转载 作者:太空宇宙 更新时间:2023-11-03 12:31:02 26 4
gpt4 key购买 nike

我正在尝试根据类似于

的配置设置为 Quarz.net 中的作业构建触发器
  var keysArray = [1,2]
keysArray.ForEach(key =>
{
//schedule will be unique for a key
var schedule = AppConfig.Get($"CronJobs.{key}.TimeSheetAutoSubmit.Schedule.QuarzExpression") ?? "0 30 23 * * ?";
var timeZoneId = AppConfig.Get($"CronJobs.{key}.TimeSheetAutoSubmit.TimeZoneId") ?? "India Standard Time";

var trigger = TriggerBuilder.Create()
.ForJob(jobDetail)
.WithCronSchedule(schedule, x => x
.InTimeZone(TimeZoneInfo.FindSystemTimeZoneById(timeZoneId)))
.WithIdentity($"TimeSheetAutoSubmitTrigger_{key}")
.WithDescription($"ConfigKey_{key}")
.StartNow()
.Build();
Scheduler.ScheduleJob(jobDetail, trigger);

});

工作正常,但问题是当我检查日志时触发器多次触发

2017-03-16 12:04:12,247 [DefaultQuartzScheduler_Worker-1] INFO  UnitedLex.Services.JobHandlers.timesheetautosubmit - job started
2017-03-16 12:04:13,510 [DefaultQuartzScheduler_Worker-2] INFO UnitedLex.Services.JobHandlers.timesheetautosubmit - job started
2017-03-16 12:04:13,710 [DefaultQuartzScheduler_Worker-2] INFO UnitedLex.Services.JobHandlers.timesheetautosubmit - job started

不知道我做错了什么....

最佳答案

我可能错了,但我认为这是正常的,因为您的作业生成器/调度程序在 foreach 中,它被触发的次数等于数组的长度。

关于c# - 为什么 Quarz.net 作业会为同一个触发器实例多次触发 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42779609/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com