Scheduling
Programming observable sequences is a powerful way to achieve a highly modularized programming experience. Although this offers high flexibility, an observable sequence is single-threaded by default and is similar to a lot of other CLR objects. This means that although a sequence can push messages to multiple subscribers, this operation happens in the same thread where the messages originate and then the messages reach all the subscribers, sequentially following their subscription order.
This means that using an observable sequence instead of any other .NET object does not convert automatically our code into a multithreaded one.
Luckily, to address this automatic multithreading need in the Rx world, there are Schedulers
. These are objects that choose when a message can flow and which thread must handle a message.
Tip
It is important to understand the huge difference that exists between using a CLR delegate
/event
and Rx scheduling. When using scheduling in Rx, we would always have...