Information Technology Reference
In-Depth Information
Overview of Source Code Components
There are five portions of code that need to be in place to use events:
Delegate type declaration
: The event and the event handlers must have a common signa-
ture and return type, which is described by the delegate type declaration.
Event handler declarations
: The declarations in the subscriber classes, of the methods
(the event handlers) to be executed when the event is raised.
Event declaration
: The declaration in the publisher class, of the event that holds and
invokes the event handlers.
Event registration
: The code that connects the event handlers to the event.
Code that raises the event
: The code in the publisher that calls the event, causing it to
invoke its event handlers.
Figure 16-4 illustrates these five components.
Figure 16-4.
The five source code components of using an event