导致死锁的异步/等待示例
async
/await
稳定性:了解同步上下文
public ActionResult ActionAsync(){ // DEADLOCK: this blocks on the async task var data = GetDataAsync().Result; return View(data);}private async Task<string> GetDataAsync(){ // a very simple async method var result = await MyWebService.GetDataAsync(); return result.ToString();}
MyWebService.GetDataAsync();
GetDataAsync().Result
GetDataAsync()
?