Skip to content

ValueTask<TResult> documentation is outdated for .NET 10 - repeated await no longer throws #12704

@AnastasiaGolomazova

Description

@AnastasiaGolomazova

Type of issue

Typo

Description

The documentation for ValueTask on learn.microsoft.com states:

"A ValueTask instance may only be awaited once, and consumers may not read Result until the instance has completed."

In .NET 10.0.300 (release), this is no longer true. I tested the following scenarios and none of them threw an exception:

Awaiting the same ValueTask instance multiple times

Calling .AsTask() multiple times

Accessing .Result before the task completed

Calling .Preserve() after .AsTask()

The documentation should be updated to reflect the actual behavior in .NET 10

Example:

Image

Expected behavior (per docs): The second await should throw InvalidOperationException.

Actual behavior (.NET 10.0.300): Both await calls succeed and print the same result.

Environment:

.NET 10.0.300

Windows x64

Console application targeting net10.0

Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.valuetask?view=net-10.0

Content source URL

https://github.com/dotnet/dotnet-api-docs-temp/blob/live/xml/System.Threading.Tasks/ValueTask.xml

Document Version Independent Id

8146b64b-4225-5572-23b2-c959597dfb55

Platform Id

5c4fec22-5232-0ebf-2ed8-a486d802cf53

Article author

@dotnet-bot

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions