~/talk

Correcting Common Async/Await Mistakes in .NET 8

Talkat NDC Porto 2023 · 2023-10-16..10-20· [microservices]
slides:none on file

Explains how the C# compiler turns each async method into a state-machine class that wraps MoveNext in a try/catch, so unawaited Tasks silently lose exceptions; demonstrates a safe fire‑and‑forget extension (safe fire and forget) used in production (NuGet >1,000,000 downloads) to capture those exceptions. Shows specific refactors: use ConfigureAwait(false) to avoid UI-thread switches, prefer ValueTask for hot paths, use IAsyncEnumerable + Task.WhenAny to parallelize 50–100 API calls, and avoid Task.Result/Wait which cause threadpool exhaustion; measures ~100-byte per async-method overhead.

AI-written summary · about

  1. 0:00Async/await in .NET
  2. 1:31How async/await works
  3. 8:58Non-awaited tasks hide exceptions
  4. 13:32Async void in constructors
  5. 22:46Task continuation threads
  6. 29:07Avoid thread blocking with GetAwaiter
  7. 33:42Frozen collections in .NET 8
  8. 36:29Optimizing async with IAsyncEnumerable
  9. 41:27Return tasks instead of await
  10. 45:19ValueTask for hot path
  11. 50:18Summary and resources
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.