C#C
C#4y ago
Thinker

When to use ValueTask?

Despite having used C# for a while I'm... not that familiar with async. I know people sometimes say to sometimes use ValueTask<T> instead of
Task<T>
, but when should you exactly do this? The extent of my knowledge (and reading the docs) is that ValueTask<T> is like a DU between either a
T
value or a
Task<T>
, so is it ideal for situations in which an async method may just return a cached value?
Was this page helpful?