Jason
07/08/2024, 10:49 AMIRecurringBackgroundJob
up and running that supports cron expressions (human time) rather than delay/period timespans (machine time).
Do either of you know if anyone's working on cron support? I can see there's already a cron parser library in there but it's only used for first delay internally.Jason
07/08/2024, 10:50 AMRecurringHostedServiceBase
so may need to be a separate thing anyway.huwred
07/08/2024, 11:27 AMSebastiaan
07/08/2024, 11:34 AMSebastiaan
07/08/2024, 11:35 AMSebastiaan
07/08/2024, 11:39 AMJason
07/08/2024, 11:48 AMSebastiaan
07/08/2024, 11:52 AMJason
07/08/2024, 11:56 AMJason
07/08/2024, 11:58 AMAndrew McKaskill
07/08/2024, 12:24 PMAndrew McKaskill
07/08/2024, 12:25 PMAndrew McKaskill
07/08/2024, 12:25 PMAndrew McKaskill
07/08/2024, 12:26 PMAndrew McKaskill
07/08/2024, 12:30 PMAndrew McKaskill
07/08/2024, 12:37 PMTimer
object, because that's doing the multi-threading locking that causes the task to come back into context. If we get rid of that we'd need a new hosted service that was running on a short timer and constantly checking to see if there are any jobs that need doing.
So... instead, we can convert the calls that re-enable the timer to calculate a next run date/time and just set the timer for the delay between now and that time.
Because the timer is disabled and re-enabled on every execution (to ensure we don't have two copies running at once if it's a long running task) it should be easy enough to get the "next" run time every time.
We should also be able to add a new property to the common interface with the Cron pattern and pick the delay or the cron pattern based on it.
We can't change the constructor - it's really there for legacy purposes anyway incase anyone subclassed it - but we can add a new overload with cron patterns in it.Jason
07/08/2024, 12:53 PMAndrew McKaskill
07/08/2024, 12:53 PMAndrew McKaskill
07/08/2024, 12:54 PMJason
07/08/2024, 1:14 PMAndrew McKaskill
07/08/2024, 1:44 PMJason
07/08/2024, 2:26 PMskttl
07/08/2024, 9:19 PMAndrew McKaskill
07/12/2024, 3:22 PMChangePeriod
method after each execution based on the next occurence from the cron expression.
When I get a chance I'll extend the actual base class to do this properly, but this should work in the mean time.
(Note - I really hacked this together quick. It compiles, but I haven't actually run it yet 😁 )Jason
07/15/2024, 9:43 AMIBackgroundJob
with basically just the task, then having a separate IRecurringBackgroundJob
and ICronJob
would make it cleaner.Andrew McKaskill
07/15/2024, 10:27 AMJason
07/15/2024, 2:31 PMISchedule
? When the current API uses delay + period timespans (and would need to remain in place) and a cron expression would be a string.Andrew McKaskill
07/16/2024, 10:21 AMJason
08/20/2024, 4:09 PM