JavaScript is required for the interactive terminal. The essential portfolio information remains available below.
Static Markdown articles about building dependable software.
Why Calling .Result in C# Freezes Your API and How await Fixes It
Practical examples of how await works in C# and the three real problems that happen when you block a Task with .Result.
Almost every C# developer has felt the temptation at least once. You call a method that returns Task<User, you do not want to mark the current method as async, you type .Result at the end, and the code compiles right away.
In local tests with one request at a time, everything looks fine. In production, once real traffic hits your API, response times climb, timeouts appear, or requests freeze completely.
What await actually does
When you use await on a network or database call, the current thread does not sit idle waiting for the reply. It returns to the .NET ThreadPool to handle other work while the operating system waits for the database or external API to answer.
csharp
[HttpGet("orders/{id:int}")]
public async Task<IActionResult GetOrderAsync(int id, CancellationToken ct)
{
OrderDto? order = await orderService.FindByIdAsync(id, ct);
if (order is null)
return NotFound();
return Ok(order);
}
Once the database query completes, an available ThreadPool thread picks up the rest of the method and sends the HTTP response. With a small set of threads, the server can handle thousands of concurrent calls without wasting resources.