可以立即触发每周触发器然后每周触发吗?
我想知道是否可以使用每周触发器触发一次,然后转到每周计划
Trigger trigger = TriggerUtils.MakeWeeklyTrigger(
"TriggerName",
dayOfweek,
timeOfDay.Hours,
timeOfDay.Minutes);
所以我基本上希望当我的服务第一次启动触发器时触发并运行它的工作。之后,我希望它根据用户设置每周工作一次(所以也许在第一次运行后,用户将其设置为星期一上午 5:00)。
I am wondering if it is possible to use weekly trigger to fire once and then go to a weekly schedule
Trigger trigger = TriggerUtils.MakeWeeklyTrigger(
"TriggerName",
dayOfweek,
timeOfDay.Hours,
timeOfDay.Minutes);
So I basically want when my service first starts my trigger to fire and run it's job. After that I want it to work on a weekly basis based on user settings(So maybe after first run a user set it to Monday 5:00am).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将多个触发器与一项作业关联。一个将立即触发,并且仅触发一次,另一个将每周触发:
或者您可以安排立即触发,并将触发时间重新安排为每周:
另一种选择是在启动时运行代码,而不涉及 Quartz。只需使用线程池即可。然后让 Quartz 只处理每周的日程安排。如果您的代码不依赖于 Quartz,这是可能的,这通常是一个好主意。
You can have multiple triggers associated with one job. One would fire immediately and only once and the other will fire weekly:
Or you can schedule immediate trigger and when it fires reschedule to weekly:
Another option is to just run your code on start up without involving Quartz. Just use ThreadPool. And then let Quartz handle weekly schedule only. This is possible if your code does not depend on Quartz which might be a good idea in general.