Practice · 1 of 3
Linked cancellation
CHALLENGE
Difficulty: advanced+25 XP
Implement static async Task<int> RaceTask(Task<int> a, Task<int> b, CancellationToken external) returning whichever of a/b finishes first — and it must stop waiting when external cancels, throwing OperationCanceledException. Use CancellationTokenSource.CreateLinkedTokenSource and Task.WhenAny with cancellation registration.
Press Submit to check your solution.
Back to lesson: Practice: Async drills