Yes. As it says in the documentation, CancellationToken
is for cooperative cancellation.
It is for the code within the task to decide what to do with the information that a cancellation has been requested. It can ignore it, or it can wait for an appropriate point and throw an OperationCanceledException
if cancellation has been requested. There's a helper method provided that does exactly this:
CancellationToken.ThrowIfCancellationRequested()
This is far preferable to just killing a thread (though, as an aside, Task != Thread
). See this question for a bunch of reasons why Thread.Abort
is a bad idea.