← C# Programming learning path
C# Programming · Module 8 of 10

Async programming

Write responsive code with async and await.

📖 Key ideas

  1. async methods return Task or Task<T>.
  2. await waits without blocking the thread.
  3. Use async for I/O: HTTP calls, files, databases.
  4. Task.WhenAll runs tasks concurrently.
  5. Avoid async void except for event handlers.
💡 Real-life example: async/await is putting rice to cook and chopping vegetables meanwhile, instead of staring at the pot.
TaskRepresents async work
awaitWaits for a task without blocking
Task.WhenAllWaits for many tasks
CancellationTokenSignals cancellation