Using Virtual Schedulers
We've been using Virtual Schedulers throughout the book, but we've never explained how they work. Remember that anything that isn't calculated immediately in Rx is run through an IScheduler
implementation—in other words, Rx never creates a Task<T>
or calls a new Thread()
directly, it always delegates to a Scheduler
to do the actual work.
So, what if you created a Scheduler
that didn't actually do anything, but instead just recorded the time that the scheduled item should run? Then later, you could say “Go!” and it would run each item in order.
Here's the powerful part: if you've got a record of the order in which items should run in, you can also say things like, “Execute up to 10 minutes in, then stop and let me take ...
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.