Tag Archives: events

Raising custom events

How do you define and raise custom events in C#? public event EventHandler<TEventArgs> MyEvent; protected virtual OnMyEvent(TEventArgs e) { if (MyEvent != null) MyEvent(this, e); } This is fine, but now in a multi-threading environment, where things get nasty: suppose … Continue reading

Posted in .NET, C# | Tagged , , | Leave a comment