Skip to content

Instantly share code, notes, and snippets.

@cdaven
Created February 9, 2022 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdaven/9d64c588106b7d0d497b81a88d1f5a76 to your computer and use it in GitHub Desktop.
Save cdaven/9d64c588106b7d0d497b81a88d1f5a76 to your computer and use it in GitHub Desktop.
ASP.NET async Deadlock Example
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