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

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -