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

ValueTask documentation - Document behavior when ValueTask.IsFaulted is true #9925

Open
tom-puckett opened this issue May 17, 2024 · 2 comments
Labels
area-System.Threading.Tasks doc-bug Problem with the content; needs to be fixed Pri3 Indicates issues/PRs that are low priority question untriaged New issue has not been triaged by the area owner

Comments

@tom-puckett
Copy link

tom-puckett commented May 17, 2024

There is no Exception property of ValueTask<T>. It would help to explain in the remarks whether an exception can be caught in the calling code, or is it necessary to test IsFaulted, and if so, how can I discover what the fault is.

@issues-automation issues-automation bot added the Pri3 Indicates issues/PRs that are low priority label May 17, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label May 17, 2024
@ericstj ericstj added doc-bug Problem with the content; needs to be fixed question labels May 21, 2024
@colejohnson66
Copy link
Contributor

ValueTask is designed to hold either the result or a Task. It helps to remember that it is for situations where, most of the time, a result can be provided without asynchronous operations. In other words, to avoid allocations on the "happy path". As such, when a ValueTask is not immediately completed, it actually contains an inner Task that either represents the future or contains the result or exception. In other words, the exception is stored in the inner Task.

The proper way to handle any ValueTask is await it.

@tom-puckett
Copy link
Author

Thanks. The request here is to add information to that effect in the documentation page, making it more informative and useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Threading.Tasks doc-bug Problem with the content; needs to be fixed Pri3 Indicates issues/PRs that are low priority question untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

3 participants