Using CancellationToken for timeout in Task.Run does not work [duplicate]

Cancellation in Managed Threads:

Cancellation is cooperative and is not forced on the listener. The listener determines how to gracefully terminate in response to a cancellation request.

You didn’t write any code inside your Task.Run method to access your CancellationToken and to implement cancellation – so you effectively ignored the request for cancellation and ran to completion.

Leave a Comment