[英]Is it fine to “await” methods inside other “async” methods
I want to understand is it good to call one awaitable method from another one. 我想了解从另一个方法中调用一个等待的方法是否很好。 Will this cause any issues if "recursively" call methods using "await"? 如果使用“等待”以递归方式调用方法,这会引起任何问题吗?
async void AsyncMeth()
{
await AsyncMeth2();
}
If this is not good, why and what should i do? 如果这不好,我为什么以及该怎么办? Thank you. 谢谢。
It's perfectly fine to have one async
method call another one. 最好让一个async
方法调用另一个方法。
In most cases, the returned Task
is immediately await
ed: 在大多数情况下,返回的Task
会立即await
:
async Task MethAsync()
{
await Meth2Async();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.