Why CancellationToken is separate from CancellationTokenSource?

I was involved in the design and implementation of these classes. The short answer is “separation of concerns“. It is quite true that there are various implementation strategies and that some are simpler at least regarding the type system and initial learning. However, CTS and CT are intended for use in a great many scenarios … Read more

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 … Read more