Blog
Mert Özen's blog posts on software development, backend, frontend, and DevOps.
C# async void and Fire-and-Forget: Lost Exceptions
Why an exception from an async void method crashes the process without ever reaching try/catch, and how async Task fixes it. Using async void correctly in event handlers, hidden async void with List.ForEach, the silently lost failure of an un-awaited task and UnobservedTaskException, the CS4014 warning, a safe Forget extension that logs the failure, and the scope trap in ASP.NET Core.
Exceptions in C# Async: AggregateException and Errors in WhenAll
An exception in an async method goes into the task and is thrown with its original type at the await. Throwing parameter checks at the call, the difference between Wait, GetResult and await, reaching every error and partial results from WhenAll, an error order that differs between two overloads, AggregateException.Handle and unobserved task exceptions.
Exception Handling in C#: try/catch/finally, throw and Your Own Exception
Exception handling in C#: try, catch and their order, cleanup with finally and using, how throw and throw ex differ in the stack trace, the when filter, writing your own exception type and using InnerException, and when to use an exception and when TryXxx.