Click here to Skip to main content
Licence CPOL
First Posted 18 Dec 2007
Views 11,424
Downloads 165
Bookmarked 8 times

Global Event Distributor

By | 18 Dec 2007 | Article
Global event handler distributor

Introduction

This articles discusses how to add event handlers by defining custom attributes on the event definitions and their handler methods.

Background

By using EventDistirbutor, you don't need to have references between the event and its handler method class.

Using the Code

Publish your event:

[PublishEvent("OnOver")]
public event EventHandler OnOver;

Subscribe to the event:

This must be public!

[SubscriberEvent("OnOver")]
public void OnOver(object sender, EventArgs e)
{
    Console.WriteLine("OnOver From Class A");
}

History

  • 18th December, 2007: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

shaykeren

Software Developer
QualiSystems
Israel Israel

Member

shaykeren.blogspot.com

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Layout  Per page   
  Refresh
GeneralMore explaination would be good PinmemberSleepyBoBos14:46 2 Jun '08  
Generalthanks for posting anyhow Pinmemberti-oh14:56 19 Dec '07  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 18 Dec 2007
Article Copyright 2007 by shaykeren
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid