事件扩展
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());
浙公网安备 33010602011771号