dotnet / dotnet/dotnet-api-docs
ValueTask<TResult> documentation is outdated for .NET 10 - repeated await no longer throws
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
### Type of issue
Typo
### Description
The documentation for ValueTask on [learn.microsoft.com](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.valuetask-1) 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:
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
Contributor guide
Assessment
This issue has not been assessed yet.