-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Fix #10904: Task extensions synchronously complete ValueTasks #13719
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
Conversation
| #if DEBUG | ||
| VerifyTaskCompleted(task.IsCompleted); | ||
| #else | ||
| if (HasSynchronizationContext()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this is worth doing. Might break customers apps that worked just fine before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may for some custom non-blocking sync context. In that case, they will report a bug and use Task.Run as a workaround while we fix it. However, if we don't throw in this case, the most common sync context scenario of interaction with UI will hang without any clue for the user why it has happened.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is of course if we have any bugs like that at all (this exception should be thrown only if we have sync code that waits on incomplete task while should only get the result of completed).
|
Do you think it's worth adding tests? |
…Tasks (Azure#13719)" This reverts commit 49bcc3e.
In release builds, correctly wait for the value task synchronously if it runs without sync context or task scheduler, otherwise throw (#11855 (comment))