Basic event handling

class EventSender
{
    public delegate void testEventHandler(object sender, EventArgs e);
 
    public event testEventHandler testEvent;
 
    public void makeEvent()
    {
		// Trigger event
        testEvent(this, new EventArgs());
    }
}
 
 
class EventReceiver
{
    EventSender eventSender;
 
    private void registerEvent()
    {
        eventSender.testEvent += new EventSender.testEventHandler(testEventHandler);
    }
 
    private void testEventHandler(object sender, EventArgs e)
    {
		// Event is handled here
    }
}

Download this snippet

This piece of code implements a basic event handler. Code should be self explanatory.

Twitter Twitter

2 Comments to “ Basic event handling”

  1. Anonymous  on Mar 14, 2010

    kbkmvg <a href="http://uudfhkqqaemq.com/">uudfhkqqaemq</a>, [url=http://quhwwxhjgrpd.com/]quhwwxhjgrpd[/url], [link=http://zqrwlsdophnm.com/]zqrwlsdophnm[/link], http://ipdpokwofafn.com/

  2. Anonymous  on Aug 01, 2010

    rfr8fd <a href="http://clufccfykavs.com/">clufccfykavs</a>, [url=http://zwrkelcahuzf.com/]zwrkelcahuzf[/url], [link=http://kejpfnmaksfo.com/]kejpfnmaksfo[/link], http://udjdzkhadeli.com/

Leave a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>