O'Reilly logo

Programming Reactive Extensions and LINQ by Paul Betts, Jesse Liberty

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

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 ...

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