✅ 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!
Was this page helpful?