事件 示例

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);
    }
}

then just call

myEvent.Raise(this, args);

That will work for all EventHandler and EventHandler<T> events.

 

posted on 2013-04-23 09:11  武胜-阿伟  阅读(180)  评论(0编辑  收藏  举报