Skip to content

Instantly share code, notes, and snippets.

@OlegKarasik
OlegKarasik / Demo.cs
Last active February 21, 2025 14:33
Code Tip: How to work with asynchronous event handlers in C#?
public class Demo
{
public event EventHandler DemoEvent;
public void Raise()
{
this.DemoEvent?.NaiveRaiseAsync(this, EventArgs.Empty).GetAwaiter().GetResult();
Console.WriteLine("All handlers have been executed!");
}
}