Raising Shared Events

Chapters 8 and 9 explained dynamic programming afforded to us by events and event handlers, all falling under the auspices of the Delegate class.

Keep in mind that RaiseEvent incurs no penalty if there are no respondents. If you write your code to invoke a specific method, at runtime you are stuck with the behavior described by that respondent. However, if you define an event and raise the event, any respondent can answer the event. Consider the revised code from Listing 11.9, shown in Listing 11.10, that demonstrates using a fixed respondent to indicate to the consumer of HasOverloaded that a Print method was invoked. (Parts of the original code from Listing 11.9 were concealed with code outlining to shorten the listing.) ...

Get Visual Basic® .NET Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.