I've got a situation where I have two async methods that both have the same return type and one calls the other without changing the shape of the data.
public async Task<int> Foo() { return 1; }
public async Task<int> Bar()
{
return await Foo();
}
Is there any reason to use async
/await
in the Bar
function or can I simply return the task created by the inner method?
So, for example, is this version of Bar
more performant? Does it produce one less block?
public Task<int> Bar()
{
return Foo();
}
What's actually happening behind the scenes when async calls are chained in this way?