.NET Developer Interview Question

What actually happens when you await a task in C#?

What the interviewer is probing, how to structure your answer, and a spoken example you can adapt.

Quick answer

The compiler rewrites an async method into a state machine. When execution reaches an await on a task that has not finished, the method returns to its caller and the thread is released for other work. When the task completes, the rest of the method runs as a continuation, on the captured synchronisation context if there is one, otherwise on a thread pool thread. No thread sits blocked waiting for the I/O.

Why interviewers ask this

Async code is everywhere in .NET, and many developers use it correctly by habit without understanding it, which falls apart the first time they meet a deadlock or thread pool starvation. The interviewer wants the state machine, the release of the thread and the continuation model. Knowing that async improves scalability rather than raw speed, and that awaiting an already completed task carries on synchronously, shows real depth.

How to structure your answer

  • Explain the compiler generated state machine.
  • Describe what happens at an await on an incomplete task.
  • Cover where the continuation runs and why context matters.
  • Say what async buys you: scalability, not speed.

Example answer

Spoken example, first person

When I mark a method async, the compiler turns it into a state machine, with each await as a point where the method can pause and resume. At runtime, if I await a task that has already completed, execution just carries on synchronously with no thread switch. If the task is still running, say a database call, the method registers the rest of itself as a continuation and returns an incomplete task to its caller. The important bit is that the thread is released. Nothing sits blocked waiting for the network; the I/O completes through the operating system, and then the continuation is scheduled. Where it resumes depends on context. In a desktop app it posts back to the UI thread by default, which is why ConfigureAwait false matters in library code there. ASP.NET Core has no synchronisation context, so it resumes on any thread pool thread. What async buys you is scalability rather than speed. A single request is not faster, but the same threads can serve far more concurrent requests, because none are parked waiting on I/O.

Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.

See how it works

Follow-up questions to expect

  • What does ConfigureAwait false do, and does it matter in ASP.NET Core?
  • When would you return a ValueTask instead of a Task?
  • Why is async void dangerous outside event handlers?

Related .net developer questions

Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.

Predict my questions

Rehearse the hard questions before they are asked

Practise with a live copilot, then walk in ready. A $29 Session Pass gets you through the interview with no subscription and no lock-in.

Get GhostPilot