Question

I'm new to Quartz.Net and I'm wondering what happens if a job is scheduled in the past? Is an exception thrown? Is it run immediately? I'm wondering if I need to guard for this condition when I schedule jobs.

Was it helpful?

Solution

You will get an exception if the trigger you are adding would never fire. There is a distinction here to note: you can schedule start time to be in the past but there needs to be some future time for the trigger to fire. So having start time of NOW()-1d is fine if you have firing happening after the time you add the trigger (EndTimeUtc in the future AND schedule that permits futher fires from now).

So you should check that GetNextFireTimeUtc returns non-null value for trigger you are adding.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top