Handling and raising events

As we mentioned in the introduction of this chapter, events are any actions, such as a keypress, mouse movement, or I/O operation, performed by the user. Sometimes, events can be raised by system-generated operations such as creating/updating a record in a table.

.NET Framework events are based on the delegate model, which follows the observer pattern. The observer pattern allows a subscriber to register for notifications and a publisher to register for push notifications. It's like late binding and is a way for an object to broadcast that something has happened.

A design pattern that allows you to subscribe/unsubscribe to a stream of events coming from a publisher is called an observer pattern.

For example, ...

Get Programming in C#: Exam 70-483 (MCSD) Guide 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.