async and await
Context: The async and await keywords are the core of asynchronous programming in C#. They allow you to write non‑blocking code that looks like synchronous code.
How it works
Section titled “How it works”asyncmarks a method as asynchronous, allowing the use ofawait.awaitsuspends the method until the awaited task completes, without blocking the thread.
public async Task ProcessDataAsync(){ Console.WriteLine("Start"); await Task.Delay(1000); // non‑blocking wait Console.WriteLine("After delay");}Real-world usage example
Section titled “Real-world usage example”Web API controllers: Mark actions as async and await database calls, HTTP calls, or file I/O.
Example: ASP.NET Core async actions improve scalability.