Skip to content
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

Use TaskCompletionSource.RunContinuationsAsynchronously #6573

Merged
merged 1 commit into from
Jun 5, 2020

Conversation

@benjaminpetit benjaminpetit merged commit 38d4afb into dotnet:master Jun 5, 2020
@ReubenBond ReubenBond deleted the fix/tcs-rca branch June 5, 2020 22:59
sergeybykov pushed a commit that referenced this pull request Jun 30, 2020
Comment on lines 205 to 207
//Due to call to Read, this is for sure a IOException and can be thrown out.
var tcs = new TaskCompletionSource<int>();
var tcs = new TaskCompletionSource<int>(TaskCreationOptions.RunContinuationsAsynchronously);
tcs.SetException(e);
Copy link
Contributor

@icanhasjonas icanhasjonas Jul 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually makes less sense in this context. You're not in an async context, and the task you are returning is already completed. You should opt for using Task.FromException() and Task. FromCanceled

Copy link
Member Author

@ReubenBond ReubenBond Jul 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well spotted. The PR was mostly find and replace. When these methods were originally written, FromException and FromCanceled weren't available (neither was Task.CompletedTask), hence the TCS.

Would you be willing to PR your suggestion?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I figured as much :-)
I can do

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @icanhasjonas, I appreciate the effort

@github-actions github-actions bot locked and limited conversation to collaborators Dec 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants