Chapter 6. Events
In a component-oriented program, an object provides services to clients by letting clients invoke methods and set properties on the object. But what if a client (or more than one client, as shown in Figure 6-1) wants to be notified about an event that occurs on the object’s side? This situation is very common, and almost every application relies on some sort of event subscription and publishing mechanism.
Figure 6-1. A publishing object can fire events at multiple subscribing clients
Because events are actually nothing more than method calls, there is nothing inherently special about firing events, and therefore I have chosen not to consider event support as a core principle of component-oriented programming. However, that doesn’t mean that the component technology used should not try to ease the task of subscribing to and publishing events. Not surprisingly, .NET event support automates the process as much as possible. This chapter starts by describing the essential concepts of .NET event support and then provides a set of practical guidelines for effectively managing events and extending the basic event support.
Get Programming .NET Components, 2nd Edition 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.