<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dawn D</title>
    <description>The latest articles on DEV Community by Dawn D (@dawn_d).</description>
    <link>https://dev.to/dawn_d</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3944737%2Fb9e32b2d-4a7f-422e-a6f0-36ef64bbac06.png</url>
      <title>DEV Community: Dawn D</title>
      <link>https://dev.to/dawn_d</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dawn_d"/>
    <language>en</language>
    <item>
      <title>Understand .NET ConfigureAwait(), .Result and await</title>
      <dc:creator>Dawn D</dc:creator>
      <pubDate>Wed, 17 Jun 2026 16:14:22 +0000</pubDate>
      <link>https://dev.to/dawn_d/understand-net-configureawait-result-and-await-1kob</link>
      <guid>https://dev.to/dawn_d/understand-net-configureawait-result-and-await-1kob</guid>
      <description>&lt;p&gt;Imagine you're going to a bank to file some paperwork.&lt;/p&gt;

&lt;p&gt;You hand your files to a window, then you have two choices:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Stand at the window&lt;/strong&gt;, never leave until you get the result — even if an earthquake hits.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Wait in the lobby&lt;/strong&gt; and do your own thing, until you are called.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Option 2 is what &lt;code&gt;await&lt;/code&gt; does. Option 1 is what &lt;code&gt;.Result&lt;/code&gt; does. The trick is in &lt;em&gt;which window&lt;/em&gt; calls you back — and that's where &lt;code&gt;.ConfigureAwait(false)&lt;/code&gt; comes in.&lt;/p&gt;

&lt;h2&gt;
  
  
  The mental model
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Request (you)&lt;/strong&gt; = the calling code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bank vault&lt;/strong&gt; = the async operation doing its work in the background.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Window / clerk&lt;/strong&gt; = a thread that delivers the result back to you.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SynchronizationContext&lt;/strong&gt; = the rule that says &lt;em&gt;which&lt;/em&gt; window must deliver your result (e.g. "always window #3").&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In a UI app (WPF, WinForms) or classic ASP.NET, there's always an assigned window — it's the UI thread or the request thread. In ASP.NET Core or a console app, there is &lt;strong&gt;no assignment&lt;/strong&gt; — any free clerk can deliver the result.&lt;/p&gt;

&lt;h2&gt;
  
  
  The three options side by side
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// 1. await — go wait in the lobby, come back to my ASSIGNED window&lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;GetDataAsync&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// 1. await — go wait in the lobby, come back to my ASSIGNED window, .ConfigureAwait(true) is not neccessary&lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;GetDataAsync&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;ConfigureAwait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// 2. await + ConfigureAwait(false) — go wait in the lobby, come back to ANY free window&lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;GetDataAsync&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;ConfigureAwait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// 3. .Result — stand at the window, refuse to move until I have the receipt, even the earthquake come&lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;GetDataAsync&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;Result&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;await&lt;/code&gt; (default) = "I leave the lobby; when ready, deliver through &lt;strong&gt;my assigned window&lt;/strong&gt;."&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;await ... .ConfigureAwait(false)&lt;/code&gt; = "I leave the lobby; when ready, deliver through &lt;strong&gt;any free window&lt;/strong&gt;."&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.Result&lt;/code&gt; = "I block the lobby; I will not move until the receipt is in my hand."&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  When to actually use it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In your own &lt;strong&gt;ASP.NET Core&lt;/strong&gt; services and controllers: skip it. ASP.NET Core has no assigned windows — &lt;code&gt;.ConfigureAwait(false)&lt;/code&gt; does nothing.&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;library code&lt;/strong&gt; (NuGet packages, shared infrastructure): use it everywhere as defensive armor — you don't know if a caller might block on &lt;code&gt;.Result&lt;/code&gt; from WPF or classic ASP.NET.&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;WPF / WinForms / classic ASP.NET&lt;/strong&gt; app code: use &lt;code&gt;await&lt;/code&gt; (default) when you need to touch the UI or request state after the await; switch to &lt;code&gt;.ConfigureAwait(false)&lt;/code&gt; only for work that doesn't need the original context.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Never&lt;/strong&gt; mix &lt;code&gt;.Result&lt;/code&gt; (or &lt;code&gt;.Wait()&lt;/code&gt;) with async code unless you have a very specific reason — that's the only situation where this whole discussion matters.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;await&lt;/code&gt; = leave the lobby, come back through &lt;em&gt;my&lt;/em&gt; window.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.ConfigureAwait(false)&lt;/code&gt; = leave the lobby, come back through &lt;em&gt;any&lt;/em&gt; window.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.Result&lt;/code&gt; = block the lobby until the receipt arrives.&lt;/li&gt;
&lt;li&gt;Deadlock = &lt;code&gt;.Result&lt;/code&gt; blocks the very window the continuation insists on using.&lt;/li&gt;
&lt;li&gt;ASP.NET Core has no assigned windows, so the whole problem doesn't exist there.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>beginners</category>
      <category>csharp</category>
      <category>dotnet</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
