✅ Scheduling with irregular and long intervals
Hello, I'm developing an app that will run 24/7 on a server, and I want to schedule it to do something. It's a console app running .NET 7.
I want it to do a thing every hour between 8-16 on wednes, in which it's checking if something has been updated. If it hasn't it will keep doing this for the next two days as well. If it finds an update, or there is no update within 16:00 on Friday, it will stop looking and wait until the next Wednesday and start over again.
The app is entirely based around async Task operations, and technically I could have a while loop with calls to Task.Delay with very high values, but that method just doesn't seem very viable to me. It could result in an almost 7 day long waiting time, and that seems like it's not a great way to use Task.Delay.
So, I'm looking for some tips and suggestions on a good way to schedule the app to work the way I've described. Alternatively if using Task.Delay is a perfectly viable way to achieve this, then please let me know and I'll just do it that way!
3 Replies
I haven't use but Azure Functions can be handy if you don't have business limitation to use external services like azure https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer?tabs=in-process&pivots=programming-language-csharp
External services are a no go, unfortunately
you can try QUARTZ.NET or Hangfire
you might think it's for ASP.NET but actually no