gpt4 book ai didi

c# - Rx 调度程序选项已弃用

转载 作者:太空狗 更新时间:2023-10-29 21:12:56 26 4
gpt4 key购买 nike

我正在尝试开始使用 Reactive Extensions (Rx)。这是我编造的一个小例子:

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

obs.Subscribe(Console.WriteLine);

Console.ReadLine();

当我使用 Scheduler.ThreadPoolScheduler.NewThread 等时,我收到此警告:

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.

如果我按照警告的说明进行操作,我仍然会收到警告。如果我想使用过去可通过 Scheduler 类获得的各种选项,我究竟应该为调度程序使用什么?

最佳答案

大多数调度器都应该有一个默认实例。您应该能够使用 NewThreadScheduler.DefaultThreadPoolScheduler.Instance

关于c# - Rx 调度程序选项已弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23158180/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com