sentry-dotnet
sentry-dotnet copied to clipboard
.NET CancellationToken is cooperative - Check if it's cancelled.
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
.
Do you have specific places in mind?
I guess: Before anything expensive, inside loops.
@mattjohnsonpint @bruno-garcia shall we run through the usages on a call, and see if we find any?