Is there any scenario where writing method like this:
public async Task DoSomethingAsync()
{
// Some synchronous code
If you don't need async
(i.e., you can return the Task
directly), then don't use async
.
There are some situations where return await
is useful, like if you have two asynchronous operations to do:
var intermediate = await FirstAsync();
return await SecondAwait(intermediate);
For more on async
performance, see Stephen Toub's MSDN article and video on the topic.
Update: I've written a blog post that goes into much more detail.