惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
WordPress大学
WordPress大学
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
小众软件
小众软件
人人都是产品经理
人人都是产品经理
美团技术团队
Blog — PlanetScale
Blog — PlanetScale
S
SegmentFault 最新的问题
博客园 - 【当耐特】
V
V2EX
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 叶小钗
Google DeepMind News
Google DeepMind News
量子位
罗磊的独立博客
月光博客
月光博客
N
Netflix TechBlog - Medium
大猫的无限游戏
大猫的无限游戏
博客园_首页
P
Proofpoint News Feed
Jina AI
Jina AI
云风的 BLOG
云风的 BLOG
博客园 - 司徒正美
腾讯CDC

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Understand .NET ConfigureAwait(), .Result and await
Dawn D · 2026-06-18 · via DEV Community

Dawn D

Imagine you're going to a bank to file some paperwork.

You hand your files to a window, then you have two choices:

  1. Stand at the window, never leave until you get the result — even if an earthquake hits.
  2. Wait in the lobby and do your own thing, until you are called.

Option 2 is what await does. Option 1 is what .Result does. The trick is in which window calls you back — and that's where .ConfigureAwait(false) comes in.

The mental model

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

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 no assignment — any free clerk can deliver the result.

The three options side by side

// 1. await — go wait in the lobby, come back to my ASSIGNED window
var result = await GetDataAsync();

// 1. await — go wait in the lobby, come back to my ASSIGNED window, .ConfigureAwait(true) is not neccessary
var result = await GetDataAsync().ConfigureAwait(true);

// 2. await + ConfigureAwait(false) — go wait in the lobby, come back to ANY free window
var result = await GetDataAsync().ConfigureAwait(false);

// 3. .Result — stand at the window, refuse to move until I have the receipt, even the earthquake come
var result = GetDataAsync().Result;

  • await (default) = "I leave the lobby; when ready, deliver through my assigned window."
  • await ... .ConfigureAwait(false) = "I leave the lobby; when ready, deliver through any free window."
  • .Result = "I block the lobby; I will not move until the receipt is in my hand."

When to actually use it

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

TL;DR

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