As a general rule, I recommend you completely ignore TaskCanceledException
. Some APIs just raise OperationCanceledException
, even if they deal with cancelled tasks. And since TaskCanceledException
derives from OperationCanceledException
, your cancellation exception handler code can just use OperationCanceledException
, ignore ``TaskCanceledException completely, and it will work everywhere.