Thread safe event raising
Allows thread-safely raise any event.
Source
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);
}
}
}
Example
public event EventHandler<SomeEventArgs> SomeEvent;
SomeEvent.Raise(this, e);
Author: Marcin Kozub
Submitted on: 27 sep. 2013
Language: C#
Type: System.EventHandler<T>
Views: 5411