4 ms·
but shouldnt it be that ValueTask is used everywhere by default and class "exists for some usecase"?
by tester34 5y ago
but shouldnt it be that ValueTask is used everywhere by default and class "exists for some usecase"?
- jayd16 5y agoIt kind of depends. Class is safer because you can have multiple calls to await and the TPL was designed to be mostly as safe as possible by default....but yeah, it does hurt that its not alloc free.
- oaiey 5y agoShould: yes. Can: no. Why: backward compatibility
- Matthias247 5y agoIf you know that an operation will not complete sychronously (e.g. because it requires a network transaction) then normal Task might actually be more efficient, because the heap allocation would be required anyway and you safe the additional branches.