deadlockdetection
deadlockdetection copied to clipboard
SynchronizationContext is reset after first await
I've been testing in ASP.NET and have spotted what I think is a pretty big bug.
When I await for the first time, the continuation runs with the AspNetSynchronizationContext not the expected DeadlockDetectionSynchronizationContext, so I can only detect deadlocks in a small subset of situations.
Thankfully it appears that this can be fixed by using Delegate.Combine, SetSynchronizationContext(this) and the SendOrPostCallback d parameter in the Post method. I need to do some further investigation to see if this is specific to just ASP.NET and if I need to also implement this in the Send method.
Except a PR regarding this in the next few days.
@slang25 did you ever do that PR?
No, I have never received a follow-up from @slang25 and I don’t really know what the solution is. I hope he will submit a pull request.
Hello, I did make a start a few months ago, but got myself into a bit of a muddle with it, I'll make another take at it tomorrow and let you know how I get on.
I've submitted a PR that fixes this: https://github.com/ramondeklein/deadlockdetection/pull/5