.NET developer

Stage 2 · Lesson 6 of 6

Blocking, cancellation and async streams

C# for real work: LINQ, collections, generics and async

Three async habits separate juniors from people a team trusts. First, never block on async code with .Result or .Wait(). Under load, blocked threads pile up, the starves and response times jump from milliseconds to seconds.

Go async all the way up instead. Second, pass a CancellationToken through every call that takes time. ASP.NET Core gives each request a token that fires when the client disconnects, so EF Core and can stop work nobody is waiting for.

Third, IAsyncEnumerable<T> with await foreach streams items as they arrive instead of loading everything first; in .NET 10 it also feeds . Also remember that one must not run two queries at once.

Common trapaccepting a parameter and never passing it on to the slow calls.

A question to check yourself, an AI practice session and 3 cheat sheet entries come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

Practise

  • Keep going on the C# track: the later exercises lean on LINQ, generics and dictionaries

  • Solve easy array and hash map problems in C# to make collections and LINQ automatic

Keep handy

  • Return to the official C# modules on collections, LINQ and async when something is unclear

Also worth your time

Mark this stage as not done?