Events enable a or object to notify other classes or objects when something of interest occurs. The class that sends (or raises) the event is called the publisher and the classes that receive (or handle) the event are called subscribers.
Events have the following properties:
-
The publisher determines when an event is raised; the subscribers determine what action is taken in response to the event.
-
An event can have multiple subscribers. A subscriber can handle multiple events from multiple publishers.
-
Events that have no subscribers are never called.
-
Events are typically used to signal user actions such as button clicks or menu selections in graphical user interfaces.
-
When an event has multiple subscribers, the event handlers are invoked synchronously when an event is raised. To invoke events asynchronously, see .
-
Events can be used to synchronize threads.
-
In the .NET Framework class library, events are based on the delegate and the base class.