Based on your comment, your goal is to run specific code at specific intervals:
Conceptually, a timer is better than disabling a stream. This requires timers. If you choose a sleep approach with a thread, I think that in practice it will work fine, although it is better to use timers.
There is a third approach - using the task scheduler. You can use the Windows task scheduler or the more powerful quartz.net ( nuget package here ).
It really is a question of how you value the semantic correctness of pragmatism.
- From the point of view of semantic correctness, the best approach is to use the task scheduler, since you really want to schedule work.
- From a pragmatic point of view, the best approach is probably to simply continue using the service already developed , even if it causes the thread to sleep and spend its time on something other than changing fully working code.
More Views on Timer and Task Scheduler: Best Timer to Use in a Windows Service
source share