如何创建在石英中等待的触发器
我创建了一个作业和一个触发器,
var jobKey = new JobKey("awesome job", "awesome group");
q.AddJob<HelloWorldJob>(jobKey, j => j
.WithDescription("my awesome job"));
q.AddTrigger(opts => opts
.ForJob(jobKey)
.WithIdentity("HelloWorldJob-trigger")
.WithSimpleSchedule(x => x.WithIntervalInSeconds(5))
可以在这样的控制器中称呼它,
var scheduler = await schedulerFactory.GetScheduler();
await scheduler.TriggerJob(jobKey);
但是问题是在启动应用程序时开始作业
是否可以保持触发空闲?这样我稍后可以手动触发它?
我发现了一些类似的问题,建议将来将startat
方法放在以后的日期,但是这个问题是旧的,也许有更合适的方法可以做到这一点?
I created a job and a trigger
var jobKey = new JobKey("awesome job", "awesome group");
q.AddJob<HelloWorldJob>(jobKey, j => j
.WithDescription("my awesome job"));
q.AddTrigger(opts => opts
.ForJob(jobKey)
.WithIdentity("HelloWorldJob-trigger")
.WithSimpleSchedule(x => x.WithIntervalInSeconds(5))
I can call it in a controller like this
var scheduler = await schedulerFactory.GetScheduler();
await scheduler.TriggerJob(jobKey);
But the problem is that the job starts when application is started
Is there a way to keep trigger idle? so I can trigger it later manually?
I found some similar questions where it was suggested to put in StartAt
method a date long in future, but this questions were old, maybe there is a more appropriate way of doing it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要添加触发器,请在要手动触发作业时调用iScheduler.triggerjob。将作业添加为Scheduler Init中的耐用性,因此它不需要触发器参考它。
Don't add a trigger, call IScheduler.TriggerJob when you want to manually trigger the job. Add the job as durable in scheduler init so it doesn't need to have triggers referring to it.