事件 示例

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.

 

你可能感兴趣的:(事件)