How Events Work

Approaching events from a C# language angle, there’s not much to them. Events are declared as members of a class or a struct, with the common set of available modifiers such as the static keyword and the visibility modifiers. From a typing perspective, an event must be declared with a delegate type. For example:

public event Action Finished;

As you will see, it’s a common recommended practice to use certain delegate types for events to create a common experience across the board. For now, we’ll ignore this and focus on the inner workings of events for a minute or two.

What do events consist of on the inside? Let’s make some informed guesses before taking a closer look with ILDASM. First, events are a different sort of member ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.