Created
October 1, 2018 14:25
-
-
Save ProductiveRage/f3ae688d7af3fca2f8eeec5ac6844e7c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HomeController : Controller | |
{ | |
public ActionResult Index() | |
{ | |
return View( | |
GetTitleAsync().Result | |
); | |
} | |
private async static Task<string> GetTitleAsync() | |
{ | |
// Using ConfigureAwait(false) here is all well and good... | |
return await GetNestedTitleAsync().ConfigureAwait(false); | |
} | |
private async static Task<string> GetNestedTitleAsync() | |
{ | |
// .. but it doesn't remove the context from here (where there is | |
// no ConfigureAwait call) and so a deadlock will still occur! | |
await Task.Delay(1000); | |
return "abc"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment