Three related idioms: event, delegate, event-handler. I always get confused by who is \"added\" to who.
event += handler
event += delegate
handler += delegate
>
The event has a delegate
added to it which "points" to a handler.
So basically, when the event
is raised, the collection of delegates it has, will be invoked, which as result will invoke handlers connected to those delegates.
//declare delegate
public delegate void EventHandler( Object sender, EventArgs e)
//create event based on delegate
public event EventHandler evHandler;
//function to attach to handler
public static void Handler(object sender, EventArgs e) {}
attach eventhandler function through delegate to event.
event += new EventHandler(Handler);