The documentation on CancellationToken.CanBeCanceled
describes what it does, but doesn't mention when it can ever be false. Hence it's not entirely clear to me when I should pay attention to this property.
In which circumstances can it be false and when should I look at it?
Well, CancellationToken.None returns one that isn't cancellable.
If you're the user of an API that insists on receiving a CancellationToken, but you've got no interest in ever attempting to cancel the work, then you could just pass it this token.
As someone building an API, you may be able to make certain optimizations if CanBeCancelled returns false - maybe it's "expensive" for you to check the IsCancellationRequested property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With