有没有机会避免等待?
例如我们想要的:
async Task SomeTask()
{
await ChildTask();
//Then something we want to be done without waiting till "Child Task" finished
OtherWork();
}
async Task ChildTask()
{
//some hard work
}
最佳答案
捕获 Task
并在 OtherWork
完成后等待它:
async Task SomeTask()
{
var childTask = ChildTask();
//Then something we want to be done without waiting till "Child Task" finished
OtherWork();
await childTask;
}