21
Events
·Events are specialized delegates that are declared and invoked by a class that wants to publish notifications.

The event handlers are functions created by an event subscriber and given to the delegate.
·A C# event uses the specialized delegate event handler of the form:

public delegate void evDelegate(
    object sender, userEventArgs eArgs
);

userEventArgs is a subscriber defined class, derived from System.EventArgs.  You usually provide it with a constructor to allow you to specify information for the event to use.
·The event is then declared by the publisher as:

public event evDelegate evt;

Either publisher or subscriber has to create a delegate object, eveDel, and pass it to the other participant.
·The event is invoked by the publisher this way:

evDel(
  this, new userEventArgs(arg)
);
·The subscriber adds an event handler function, myOnEvent, to the event delegate this way:

Publisher.evDelegate evDel +=
new Publisher.evDelegate(myOnEvent);
·