Events Revisited

Before getting back to our example, let’s reestablish the way we look at events. Recall how the typical event pattern is based on EventHandler<T> as the signature of an event and its handlers:

public delegate void EventHandler<TEventArgs>(object sender, TEventArgs e);

Every time such an event is raised, we get some data that travels from the event source to the listener, represented as an instance of the TEventArgs argument. In other words, it’s fair to say that events are data sources. For example, in our CountDown example the event source is really a data source producing decreasing values representing the number of seconds that are left until the countdown finishes.

When someone says “data,” they immediately think about querying ...

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.