[英]async/await Asp.Net Core when is async required?
Will the IO bound code in this context be put on the IO thread? 在这种情况下,将IO绑定代码放在IO线程上吗? Or do I need to make the Get method
async
and await PassThroughTask
? 还是我需要使Get方法
async
并await PassThroughTask
?
//Some controller class
[HttpGet]
public Task<ActionResult> Get()
{
PassThroughTask();
return Ok("passthrough");
}
public async Task PassThroughTask()
{
//Is this going to stop the IoBoundWork from going to the IO thread?
await SomeIoBoundWorkAsync();
}
public async Task SomeIoBoundWorkAsync(){ //await async io stuff}
Or do I need to make the Get method async and await PassThroughTask?
还是我需要使Get方法异步并等待PassThroughTask?
Yes. 是。
The return Ok("passthrough");
return Ok("passthrough");
statement is a lie. 陈述是谎言。 You don't know how many exceptions were thrown, you didn't listen.
您不知道抛出了多少异常,您没有听。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.