❔ What happening in background when i return Task.CompletedTask?
I just wonder, what c# doing if i have async method returning Task.completedTask? does it try to synchronously continue without actualy creating a task?
7 Replies
it's not async 🤔
^
in that example you're just returning a completed task, there's nothing async there
so even if there's Task as return, it will invoked as sync function even if i do
await Foo()
?there's nothing to await, it just synchronously returns a completed task
so c# i can say: removes async if async is not used?
it doesn't remove it, but you don't actually get any benefits of async
you just end up with more overhead
that specific method isn't async because it doesn't await anything in its body, that's just a normal method that returns a task
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.