Skip to content

Task extensions synchronously complete ValueTasks #10904

@juunas11

Description

@juunas11

In the Core project TaskExtensions, GetAwaiter().GetResult() is called on ValueTasks. According to this article by Stephen Cleary:

However, this will not work for value tasks. You simply cannot block on value tasks. If you must block (again, this is never ideal), then you’ll need to convert the value task to a reference task by calling AsTask, and then block on that reference task.

So the extensions may work but are dependent on undefined behaviour. AsTask() should be called on the ValueTask first before consuming it synchronously.

Metadata

Metadata

Assignees

Labels

Azure.CoreClientThis issue is related to a non-management packagebugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions