Information Technology Reference
In-Depth Information
Events Are Like Delegates
The preceding chapter covered delegates. Many aspects of events are similar to those of
delegates. In fact, an event is like a simpler delegate that is specialized for a particular use.
Figure 16-1 illustrates that, like a delegate, an event has methods registered with it, and invokes
those methods when it is invoked.
The following are some important terms related to events:
Raising an event: The term for invoking or firing an event. When an event is raised, all
the methods registered with it are invoked—in order.
￿
Publisher : A class or struct that makes an event available to other classes or structs for
their use.
￿
Subscriber : A class or struct that registers methods with a publisher.
￿
Event handler : A method that is registered with an event. It can be declared in the same
class or struct as the event, or in a different class or struct.
Figure 16-1. Publishers and subscribers
Search WWH ::




Custom Search