Created
February 9, 2022 14:03
-
-
Save cdaven/9d64c588106b7d0d497b81a88d1f5a76 to your computer and use it in GitHub Desktop.
ASP.NET async Deadlock Example
This file contains hidden or 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
using System.Threading.Tasks; | |
using System.Web.Mvc; | |
namespace DeadlockExperiment.Controllers | |
{ | |
public class DeadlockController : Controller | |
{ | |
public ActionResult Index() | |
{ | |
AsyncMethod().Wait(); // Deadlock! | |
return View(); | |
} | |
private async Task AsyncMethod() | |
{ | |
await Task.Delay(1000); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment