I need to write a piece of code that is:
- Run on every configured interval
- Stops after a certain amount of time OR after a condition is met.
I found that I can use a Task
with CancellationToken
but I can't see any option to run a it again and again within an interval.
Another option I saw is to use System.Threading.Timer
- but then I can't cancel the process if a condition is met.
Can someone suggest an elegant solution ?