我有一个ASP.NET WEB API控制器,其方法如下:
[HttpGet]
[Route("some/route/to/endpoint")]
public Task<Data> DoStuffAsync()
{
var somevar = Guid.NewGuid();
return DoSomeInternalStuffAsync();
}
private async Task<Data> DoSomeInternalStuffAsync()
{
var result = await SomeReallyInternalThingsAsync();
return result.Data;
}
取消异步/等待并像实际使用它一样有什么区别
[HttpGet]
[Route("some/route/to/endpoint")]
public async Task<Data> DoStuffAsync()
{
var somevar = Guid.NewGuid();
return await DoSomeInternalStuffAsync();
}
我阅读了很多文章和Stackoverflow帖子,但是我仍然不清楚:
到目前为止已阅读的文章:Eliding async await,Asynchronous Programming,Stackoverflow Thread 1,Stackoverflow Thread 2
更新:评论中回答了我的问题。