Existe algum cenário em que escrever método como este:
public async Task<SomeResult> DoSomethingAsync()
{
// Some synchronous code might or might not be here... //
return await DoAnotherThingAsync();
}
em vez disso:
public Task<SomeResult> DoSomethingAsync()
{
// Some synchronous code might or might not be here... //
return DoAnotherThingAsync();
}
faria sentido?
Por que usar return awaitconstruct quando você pode retornar diretamente Task<T>da DoAnotherThingAsync()invocação interna ?
Eu vejo código return awaitem muitos lugares, acho que posso ter perdido alguma coisa. Mas, tanto quanto eu entendo, não usar palavras-chave async / wait neste caso e retornar diretamente a tarefa seria funcionalmente equivalente. Por que adicionar sobrecarga adicional de awaitcamada adicional ?