public static void Raise<T>(this EventHandler<T> handler, object sender, T args)
where T : EventArgs
{
if (handler != null)
{
handler(sender, args);
}
}
public static void Raise(this EventHandler handler, object sender,
EventArgs args)
{
if (handler != null)
{
handler(sender, args);
}
}
用法:
myEvent.Raise(this, args);
.//////
为了保障事件线程安全
if (SampleEvent != null)
SampleEvent(this, new MyEventArgs());原文:http://www.cnblogs.com/zeroone/p/4925927.html