标签:sum wait public span work OLE one int ret
1. 怎么解决async/await的无限嵌套
public async Task MyMethodAsync()
{
Task<int> longRunningTask = LongRunningOperationAsync();
// independent work which doesn‘t need the result of LongRunningOperationAsync can be done here
//and now we call await on the task
int result = await longRunningTask;
//use the result
Console.WriteLine(result);
}
public async Task<int> LongRunningOperationAsync() // assume we return an int from this long running operation
{
await Task.Delay(1000); // 1 second delay
return 1;
}
小白终于弄懂了:c#从async/await到Task再到Thread
标签:sum wait public span work OLE one int ret
原文地址:https://www.cnblogs.com/hytvszz/p/11285792.html