Skip to content

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;

@ghost ghost added the area-System.Threading label Jul 8, 2024
@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
@dotnet-policy-service
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