-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SynchronizationContext improperly restored #31
Comments
I don't know if this is true. I think it is a bit different from the SO link you post. In that SO post, it clear the SynchronizationContext of the original thread, so after await, it could run on a different thread. It is like using But here we actually give it a context and create one if there is no context. so after await, it should go back to the original thread. |
@maxisam |
@OwnageIsMagic I guess I am confused about how await work. I thought await always return to the original context and that is tied with the thread. That is why we don't use configureAwait(false) for UI related code, because it will use any available thread from the thread pool. But if we only use await, it will return to the original thread if there is a context involved. |
Ben.BlockingDetector/src/Ben.BlockingDetector/BlockingDetectionMiddleware.cs
Lines 31 to 42 in fce6c53
SetSynchronizationContext
afterawait
ing on task restores context on continuation thread (not caller).See
npgsql/npgsql#1593
https://stackoverflow.com/questions/44418761/cross-thread-exception-after-async-call/44424562#44424562
@benaadams project seems like not maintained, just for your (and others) information.
The text was updated successfully, but these errors were encountered: