Use await Task.Delay(Timeout.Infinite, stoppingToken) in BackgroundService that is event-based #112862
Replies: 1 comment 2 replies
-
Neither. First, something has a processing loop, even if your code never sees it directly. If you're working with a library for the event loop, probably there's a method you can wait on for "end of processing" status, or maybe their |
Beta Was this translation helpful? Give feedback.
-
Is it better to use await Task.Delay(Timeout.Infinite, stoppingToken) at the end or await Task.Delay(1000, stoppingToken) in loop in ExecuteAsync method of BackgroundService that is event-based, meaning it creates some client in constructor and sets up events for the client, and it will be triggered by events, so it doesn't need a loop?
Beta Was this translation helpful? Give feedback.
All reactions