Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rx Scheduler options deprecated

I'm trying to get started with Reactive Extensions (Rx). Here's a little example I cooked up:

        var query = from number in Enumerable.Range(1, 20) select number;
        var obs = query.ToObservable(Scheduler.ThreadPool);

        obs.Subscribe(Console.WriteLine);

        Console.ReadLine();

When I use Scheduler.ThreadPool, Scheduler.NewThread, etc, I get this warning:

System.Reactive.Concurrency.Scheduler.ThreadPool' is obsolete: 'This property is no longer supported due to refactoring of the API surface and elimination of platform-specific dependencies. Consider using Scheduler.Default to obtain the platform's most appropriate pool-based scheduler. In order to access a specific pool-based scheduler, please add a reference to the System.Reactive.PlatformServices assembly for your target platform and use the appropriate scheduler in the System.Reactive.Concurrency namespace. See http://go.microsoft.com/fwlink/?LinkID=260866 for more information.

If I follow the warning's instructions I still get the warning. What am I expected to use for the scheduler exactly, if I want to use the various options that used to be available via the Scheduler class?

like image 946
Gigi Avatar asked Apr 18 '14 16:04

Gigi


1 Answers

Most Schedulers should come with a default instance. You should be able to use NewThreadScheduler.Default, ThreadPoolScheduler.Instance, etc.

like image 171
cwharris Avatar answered Nov 16 '22 00:11

cwharris