Skip to content

johnkrussell/csharp-cancellation-tokens

Repository files navigation

C# Cancellation Tokens - In-Depth Demos with ASP.NET Core

This repository contains the runnable demos that accompany my blog post:
C# Cancellation Tokens In-Depth: Complete Guide with ASP.NET Core Examples

It shows practical, working examples of how to use CancellationToken in C# and ASP.NET Core applications.


Demos Included

Each demo is available as a minimal API endpoint (Program.cs) with a matching front-end page (wwwroot/index.html).

Endpoint Description
/slow A slow request that ignores cancellation (what not to do).
/slow-cancel A slow request that honours cancellation using Task.Delay(..., token).
/ticks Manual streaming with cancellation (newline-delimited ticks).
/parallel Running work in parallel with cancellation using Parallel.ForEachAsync.
/compose Composing tasks with cancellation support (multiple awaits).
/upload Throttled file upload to demonstrate mid-transfer cancellation.

About

An in-depth collection of examples of how to use cancellation tokens in C# .NET Core.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors