The Dangers of Handling Async Event Handlers in C#
March 13, 2024
• 1,331 views
async event handlers in C#async await in C#asyncasync awaitasync voidexception handling asyncc# event handlerc# eventsc# event handler asyncc# async await explaineddotnetc# async awaitc# asyncasync await c#C# eventsC# event handlersevent handlersevent handlerc# events tutorialevents in c#exceptions in c#exceptions in C#try catch c#csharp exceptionc# exception handling best practicesc# exceptionsc# try catchC#csharp
There's no dancing around this one - async event handlers in C# are an absolute nightmare. We all know we're not supposed to use async void in our code. We're taught that from day 1 when using async await in C#. But when it comes to the signatures of events, we have no choice but to use async void for our async event handlers!
In this video, I'll demonstrate what's going on with async void so you understand exactly where the problems arise. I'll also share several improvements we can work with to try and make our lives easier.
