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

fix: reset async state of continuation in ManualResetValueTaskSourceCore<TResult>.Reset #104543

Closed
wants to merge 1 commit into from

Conversation

sator-imaging
Copy link

What's fixed

ManualResetValueTaskSourceCore<TResult>.Reset method WON'T reset asynchronous state of continuation.

  • field name: _runContinuationsAsynchronously

Why need to be reset

I've wrote task instance pool using ManualResetValueTaskSourceCore, in that case, pooled task instance could behave differently depending on what previous consumer does.

Solution

core.Reset();

// reset by hand
core.RunContinuationsAsynchronously = false;

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jul 8, 2024
Copy link
Contributor

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

@sator-imaging
Copy link
Author

@dotnet-policy-service agree [company="@sator-imaging"]

@sator-imaging
Copy link
Author

@dotnet-policy-service agree

@stephentoub
Copy link
Member

Thanks, but it is by design that _runContinuationsAsynchronously is left untouched. That state is mutable regardless of the lifecycle of the instance and can be changed at any time. It's not changed by Reset so that you can set it once and not have to set it again every single time you call Reset, which happens per operation. If that doesn't meet your needs, you can explicitly set it after calling Reset.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Threading community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants