sentry-dotnet icon indicating copy to clipboard operation
sentry-dotnet copied to clipboard

.NET CancellationToken is cooperative - Check if it's cancelled.

Open bruno-garcia opened this issue 4 years ago • 3 comments

While debugging https://github.com/getsentry/sentry-dotnet/issues/692 we noticed the cancellation token isn't checked anywhere. We only pass it along in hopes that whatever API takes it will throw if the token gets cancelled.

We need to check if the token is cancelled before doing expensive stuff. Specially on loops.

Mind that just returning might have different semantics than throwing OperationCancelledException.

bruno-garcia avatar Dec 27 '20 23:12 bruno-garcia

Do you have specific places in mind?

Tyrrrz avatar Dec 28 '20 15:12 Tyrrrz

I guess: Before anything expensive, inside loops.

bruno-garcia avatar Jan 04 '21 02:01 bruno-garcia

@mattjohnsonpint @bruno-garcia shall we run through the usages on a call, and see if we find any?

SimonCropp avatar May 03 '22 12:05 SimonCropp