Using Schedulers

Operators that care about concurrency will take an IScheduler as a parameter. This lets you specify the context in which the operator will run.

Normally, and for most operators in Rx (and in LINQ), you specify what will happen, but not the context in which it will happen. Rx generally frees you from caring. This is very different from traditional imperative programming in which all synchronization is explicit, and you must manage all the elements of asynchronous programming, such as the creation of threads and locks. In traditional programming your code never suddenly runs in a background thread; you make that happen programmatically.

Rx changes that. Every time you write some code that runs in a Select() or Where() operator, ...

Get Programming Reactive Extensions and LINQ 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.