O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Pull Versus Push

The IObservable<T> and IObserver<T> interfaces might look a little weird at first, but they are actually very closely related to the well-known System.Collections.Generic interfaces IEnumerable<T> and IEnumerator<T>. In fact, they are mathematical duals. It’s normal you perceive this as rather abstract, but it’s rather simple. Follow me.

From our discussion about statements, recall that IEnumerable<T>’s primary use is the foreach loop statement. Collections implement this interface, allowing us to retrieve their data by pulling it out one by one. In fact, the consumer is in control, which makes this an interactive mechanism. To pull data from the source, the consumer asks the enumerator for more data by calling MoveNext and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required