Almost every C# developer learns async/await from a tutorial that shows the happy path – mark a method async, await a call, done. What tutorials skip is the failure mode that’s caused more production incidents and 2am pages than almost any other pattern in the language: the async deadlock. This is a walkthrough of how it actually happens, and the small set of habits that prevent it.
Contents
- Anatomy of a classic async deadlock
- The fix: await all the way
- async void: only for event handlers
- Forgetting to await
- Deferred execution in async LINQ
- ConfigureAwait(false): matters less than it used to, but still matters somewhere
- Wrapping up
- Frequently asked questions
- Sources
Anatomy of a Classic Async Deadlock
The deadlock isn’t mysterious once you see the mechanism, it’s a thread waiting on itself without realizing it.

The root cause is SynchronizationContext. In environments that have one, WinForms, WPF, and classic (pre-Core) ASP.NET,an await captures the current context by default so it can resume back on the same thread (the UI thread, or the request thread) once the awaited operation completes. That’s usually exactly what you want: it’s why UI updates after an await don’t crash with cross-thread exceptions. The problem shows up the moment something blocks that thread synchronously with .Result, .Wait(), or .GetAwaiter().GetResult() before the awaited work finishes. The continuation can’t get back onto its required thread, because that thread is sitting there blocked, waiting for the continuation. Neither side can proceed.
ASP.NET Core doesn’t have a SynchronizationContext, so this exact deadlock is less common there. But blocking on async code in ASP.NET Core isn’t free either, it ties up a thread-pool thread that could be serving another request, and under load, enough of that pattern causes thread-pool starvation, which looks like a slow, unresponsive app rather than a hard freeze. Same root mistake, different symptom.
The Fix: Await All the Way
The rule that eliminates this entire class of bug is simple to state and easy to violate under deadline pressure: once you go async, stay async, all the way up the call stack. Don’t reach for .Result or .Wait() to “just get the value synchronously” from an async method, await it instead, and let the async keyword propagate to your method’s own signature.

If you’re stuck maintaining synchronous legacy code and genuinely can’t make the caller async, Microsoft’s own guidance ranks the escape hatches: GetAwaiter().GetResult() preserves the original exception without wrapping it in an AggregateException, which makes it the least-bad option, but it still carries deadlock risk and should be treated as a last resort, not a habit.
async void: Only for Event Handlers
The second pitfall in the image above is just as common and much easier to introduce by accident: methods declared async void outside of UI event handlers. A void-returning async method has nowhere for its exceptions to go, they can’t be caught by a try/catch around the call site, because there’s no Task to observe. Depending on the host, an unhandled exception from an async void method can crash the entire process. It’s also effectively untestable, since there’s no Task for a test to await and inspect.
The only legitimate use for async void is a UI event handler, where the framework requires that exact signature. Everywhere else, return Task.
Forgetting to Await
A method call that returns a Task but isn’t awaited compiles fine – with a warning – and quietly turns into fire-and-forget. Any exception it throws is swallowed into that orphaned Task and never surfaces anywhere:
// Bug: this Task is never awaited or observed
_repository.SaveAsync(order);
return Ok();
The fix is almost always to add the missing await and if fire-and-forget really is the intent, make that explicit and handle the failure case deliberately rather than leaving it to chance.
Deferred Execution in Async LINQ
LINQ’s laziness interacts badly with async if you’re not careful. Projecting a collection with an async lambda doesn’t start any of those tasks, it just builds a query that will run them when enumerated:
// Bug: tasks haven't started yet - this is still a lazy IEnumerable<Task<User>>
var getUserTasks = userIds.Select(id => GetUserAsync(id));
var users = await Task.WhenAll(getUserTasks); // works, but easy to get subtly wrong elsewhere
// Safer: force immediate execution before awaiting
var getUserTasks = userIds.Select(id => GetUserAsync(id)).ToArray();
var users = await Task.WhenAll(getUserTasks);
Calling .ToArray() or .ToList() before you await forces the tasks to actually start, rather than leaving their execution tied to when (and how many times) something enumerates the query.
ConfigureAwait(false): Matters Less Than It Used To, But Still Matters Somewhere
You’ll see .ConfigureAwait(false) recommended everywhere, and it’s worth understanding why it exists even though its importance has shifted. It tells the awaiter not to bother resuming on the original captured context — useful because it avoids an unnecessary context-switch, and it was historically a common (if incomplete) mitigation for deadlocks in code with a SynchronizationContext.
In ASP.NET Core, there’s no SynchronizationContext to capture in the first place, so ConfigureAwait(false) doesn’t do much there. It still matters in general-purpose class libraries that might be consumed by WPF, WinForms, or other context-sensitive callers as the library author, you don’t control who’s calling you, so avoiding an unnecessary context capture is good hygiene regardless of the caller’s environment.
Wrapping Up
Almost every real-world async bug traces back to one of a handful of root causes: blocking synchronously on async code, an async void method outside an event handler, an un-awaited Task, or a lazy LINQ query that didn’t actually run when you thought it did. None of these require exotic knowledge to avoid, they require the discipline to let async propagate all the way up your call stack instead of stopping it halfway to make a signature look simpler. That discipline, and being able to explain why it matters rather than just reciting the rule, is exactly the kind of production-tested understanding that shows up in a code review and in an interview.
Frequently Asked Questions
Why does calling .Result on an async method cause a deadlock?
In an environment with a SynchronizationContext, the awaited method’s continuation needs to resume on the original thread. If that thread is blocked waiting on .Result, the continuation can never run, and the blocked thread can never unblock — each side is waiting on the other.
Can this exact deadlock happen in ASP.NET Core?
Not in the same form, since ASP.NET Core has no SynchronizationContext. Blocking on async code there still causes a problem, though — it ties up a thread-pool thread, and enough of that pattern under load causes thread-pool starvation rather than a hard freeze.
Is async void ever acceptable?
Only for UI event handlers, where the framework requires that exact signature. Anywhere else, an async void method’s exceptions have no Task to surface through, which can crash the process or fail silently depending on the host.
What happens if I forget to await a Task?
The code still compiles, with a warning, and the call becomes fire-and-forget. Any exception the task throws is swallowed into that orphaned task and never surfaces at the call site.
Should I add ConfigureAwait(false) everywhere?
It matters most in general-purpose class libraries that might be called from a context-sensitive environment like WPF or WinForms. In ASP.NET Core, there’s no SynchronizationContext to avoid capturing, so it has little practical effect there.





You must be logged in to post a comment.