ExtensionMethod.NET Home of 876 C#, Visual Basic, F# and Javascript extension methods

Thread safe event raising

Allows thread-safely raise any event.


public static class EventHandlerExtensions
    public static void Raise<T>(this EventHandler<T> eventHandler, object sender, T e) where T : EventArgs
        var handler = eventHandler;
        if (handler != null)
            handler(sender, e);


public event EventHandler<SomeEventArgs> SomeEvent;

SomeEvent.Raise(this, e);

Author: Marcin Kozub

Submitted on: 27 sep 2013

Language: C#

Type: System.EventHandler<T>

Views: 5242