no dogma blog
no dogma blog
Blog Posts
Podcast
Web API Lambda Course
Polly Course
Photos
Contact
Support this Site
About
RSS
Light
Dark
Automatic
CancellationToken
Doing Some Cleanup in a BackgroundService
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.
Feb 24, 2025
#
.NET
,
BackgroundService
,
Worker
,
CancellationToken
Throw ThrowIfCancellationRequested in a Method that Returns a Value when Using a Cancellation Token
When sending a cancellation request to a method that returns a value, you must return a value or throw an exception. Here is how to throw the exception.
Jan 3, 2024
#
C#
,
dotNet
,
async
,
CancellationToken
Simple Cancellation Token Example
Here is an example of using a cancellation token to stop the execution of a method.
Dec 28, 2023
#
C#
,
dotNet
,
async
,
CancellationToken
Cite
×