StartDelay option delays web application start and not just the scheduler
See original GitHub issueDescribe the bug
There’s possibly an issue with QuartzHostedServiceOptions.StartDelay
option which was recently introduced in 3.3.3 (via #1166).
If this value is set, all IHostedService
s after QuartzHostedService
are delayed. In a typical Asp.Net Core application this will include the web host itself. I don’t think this is the desired result.
I looked at #1166 and saw that it ultimately is about awaiting QuartzScheduler.StartDelayed
. I was surprised to learn that the implementation of StartDelayed
is a Task.Delay
followed by a Start
. I was somehow expecting a regular start and then a delay in scheduling, if it makes sense.
I hope I can offer some critique of the current implementation of QuartzScheduler.StartDelayed
. If it is the desired behavior then I think such api is redundant and leads to confusion. It’s redundant, because developers are perfectly capable of adding a delay on their own before calling Start
. As to confusion, I think that the comment in #1166:
// when we need to init another IHostedServices first
options.StartDelay = TimeSpan.FromSeconds(10);
shows that the author of that PR made the same assumption I would make and thought that StartDelayed
would return normally (quickly) and only somehow delay the scheduling (though that’s wrong thinking still as it’s prone to races; the correct approach would be to simply register other hosted services before Quartz)
Version used
3.3.3
To Reproduce
Expected behavior
StartDelay
should not cause a delay in starting other hosted services.
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (10 by maintainers)
Top GitHub Comments
No timeline at the moment, it takes some time to prepare and go trough release notes etc. It will be same kind of binary as in MyGet feed though (different version number of course).
Thanks for working on this!