Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void Raise(this EventHandler handler, object sender, EventArgs args)
- {
- if (handler != null)
- {
- handler(sender, args);
- }
- }
- // Usage:
- MyButtonClicked.Raise(this, EventArgs.Empty);
- // This works too! Evil?
- EventHandler handler = null;
- handler.Raise(this, EVentArgs.Empty);
- public event EventHandler<EventArgs> OnClicked = delegate { };
- public static void Raise(this EventHandler handler, object sender)
- {
- Raise(handler, sender, EventArgs.Empty);
- }
- public static void Raise<TA>(this EventHandler<TA> handler, object sender, TA args)
- where TA : EventArgs
- {
- if (handler != null)
- {
- handler(sender, args);
- }
- }
- protected virtual OnSomeEvent(EventArgs e){ }
- if (myEvent!= null) {
- myEvent(this, new EventArgs());
- }
Add Comment
Please, Sign In to add comment