Bryan Hogan

@bryanjhogan.bsky.social

blogger, podcaster, Microsoft MVP, https://nodogmablog.bryanhogan.net

If you use BackgroundServices you will know there is often a Task.Delay(1000, ct), but did you know if the cancellation token is cancelled during the delay, the expected TaskCanceledException is hidden making harder to do clean up work. nodogmablog.bryanhogan.net/2025/02/doin... #dotnet #c_sharp

Doing Some Cleanup in a BackgroundService | no dogma blog

If you use the Worker Service template in .NET, you may want to do some cleanup when the background service is canceled. In this post, I'll show you how to do this.

nodogmablog.bryanhogan.net