Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ProductiveRage/f3ae688d7af3fca2f8eeec5ac6844e7c to your computer and use it in GitHub Desktop.
Save ProductiveRage/f3ae688d7af3fca2f8eeec5ac6844e7c to your computer and use it in GitHub Desktop.
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