Backend development

Stage 1 · Lesson 6 of 10

async/await and Tasks

Your language and how HTTP works

serves many requests with a small pool of . That only works if your code slow work instead of blocking a thread while it waits. An async method returns a Task (or Task<T>), a promise of a result.

await pauses the method while the database or call is in progress. Meanwhile it gives the thread back to serve someone else. Task.WhenAll runs independent calls at the same time. Pass a CancellationToken through your calls, so work stops when the client disconnects.

Common trapsync-over-async: calling .Result or .Wait() on a task blocks a thread while it waits. Under load the pool runs dry, requests queue and the service stalls, even though the CPU is idle. Once you go async, stay async all the way up.

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

Resources for this stage

Start with

  • GuideFree
    Learn C#

    Microsoft · Beginner

    Official C# tutorials from the language basics through classes, LINQ and async

Practise

  • Your language track: small exercises with free mentor feedback on idiomatic code

Keep handy

  • Quick syntax lookups for your language when you forget how something is written

  • Read the HTTP overview, methods, headers and status code pages until they feel obvious

Also worth your time

Mark this stage as not done?