the .NET Framework uses a unified model for cooperative cancellation of asynchronous or long-running...
It's not the old, unreliable, yank the thread out from under running code that has no idea what happened model of
Thread.Abort. The code has to be written to deal with cancellation at times at which it deems it safe for cancellation to occur. That does mean inspecting the cancellation token at those times or calling
ThrowIfCancellationRequested, to respect the request for cancellation.
You don't have to write any additional code if your code passes the cancellation token onto another block of code, and it's that block of code that is time consuming and has been written to respect the cancellation token - when it throws the
OperationCancelledException, that will suffice to end your operation as well, provided you don't try to catch or otherwise handle that exception.