ValueTask<T>

A cheaper alternative to Task<T> that avoids an allocation when an async method usually finishes synchronously, such as a cache hit.

In more detail

It comes with rules: await it exactly once, never store it and never block on it. Default to Task<T> and switch only when a profiler shows the allocation matters.

Related terms

Taught in

References