一个快速的问题;阅读这篇文章:http://blog.stephencleary.com/2016/12/eliding-async-await.html
它通常告诉我,使用 async/await。我已经在做了。然而,他也说当你代理任务时不必使用 async 部分。
// Simple passthrough to next layer: elide.
Task<string> PassthroughAsync(int x) => _service.DoSomethingPrettyAsync(x);
// Simple overloads for a method: elide.
async Task<string> DoSomethingPrettyAsync(CancellationToken cancellationToken)
{
... // Core implementation, using await.
}
在通过时为什么不应该使用async/await?这难道不是更不方便吗,这样做有意义吗?
大家有什么想法吗?