async await - Best Practice to always throw OperationCanceledException? -
to put task in cancelled state task should throw operationcanceledexception when cancelled. otherwise task continuation not work, right?
then why find lot of examples in internet check iscancellationrequested flag of cancellationtoken , die silent death.
is best practice always throw operationcancelledexception or legit in special cases check iscancellationrequested flag , end task without throwing operationcancelledexception?
i recommended usage call throwifcancellationrequested method of cancellationtoken struct. test if cancellation has been requested , throw operationcanceledexception cancellation has been requested.
Comments
Post a Comment