I'm trying to work through Dan Sullivan's Rx Extensions training course on PluralSight. It's excellent stuff but unfortunately Rx seems to have already been changed, even though the course was only published a month ago.
我正在努力通过丹·沙利文的Rx扩展培训课程PluralSight。这是很好的东西,但不幸的是Rx似乎已经改变了,尽管这门课一个月前才出版。
Most of the changes are trivial to work out (change from three dlls to a single dll, change in namespaces used etc) but I'm struggling to understand what I should use in place of Scheduler.Dispatcher in Dan's example. I can't see anything obvious in the properties that are available in the Scheduler.
大多数更改都很简单(从三个dll更改为一个dll,更改使用的名称空间等等),但是我很难理解应该使用什么来替代调度器。调度员在丹的例子。我在调度器中看不到任何明显的属性。
Here's the code I'm trying to get working with the (refactored?) Rx library (the currenly stable version v1.0.10605)
这是我尝试使用(重构?)的代码。Rx库(货币稳定版本v1.0.10605)
var query = from number in Enumerable.Range(1, 25) select StringWait(number.ToString());
var observableQuery = query.ToObservable(Scheduler.ThreadPool);
observableQuery.ObserveOn(Scheduler**.Dispatcher**).Subscribe(n => Results.AppendText(string.Format("{0}\n", n)));
What should I be using to invoke the Observer code (Results.AppendText) on the original Dispatcher thread?
我应该使用什么来调用原始分派器线程上的观察者代码(result . appendtext) ?
2 个解决方案
#1
41
The DispatcherScheduler
has been moved to the System.Reactive.Windows.Threading
assembly. If you are using NuGet, it's in Rx-WPF
DispatcherScheduler已经移动到System.Reactive.Windows。线程组装。如果你使用NuGet,它在Rx-WPF中
#2
1
As of 2016-11-25, the reference is RX-XAML
.
截至2016-11-25日,参考文献为RX-XAML。
Unfortunately, Microsoft delisted RX v2.2.5 in favour of RX v3.1.0, which is fully cross platform. However, the cross platform libraries do not support WPF. This means that it is now difficult to find the NuGet package which works with WPF.
不幸的是,微软将RX v2.2.5退市,取而代之的是完全跨平台的RX v3.1.0。但是,跨平台库不支持WPF。这意味着现在很难找到使用WPF的NuGet包。
To work around this, if you are using WPF
+ .NET 4.5
, install any NuGet package with a dependency on RX-XAML
. For example, reactiveui-blend
depends on RX-XAML v2.2.5
, so this will now work:
要解决这个问题,如果您正在使用WPF + . net 4.5,请安装任何依赖于RX-XAML的NuGet包。例如,reactiveui-blend依赖于RX-XAML v2.2.5,因此现在可以工作了:
setClipboard.ObserveOnDispatcher().Subscribe(o =>
{
...
});
#1
41
The DispatcherScheduler
has been moved to the System.Reactive.Windows.Threading
assembly. If you are using NuGet, it's in Rx-WPF
DispatcherScheduler已经移动到System.Reactive.Windows。线程组装。如果你使用NuGet,它在Rx-WPF中
#2
1
As of 2016-11-25, the reference is RX-XAML
.
截至2016-11-25日,参考文献为RX-XAML。
Unfortunately, Microsoft delisted RX v2.2.5 in favour of RX v3.1.0, which is fully cross platform. However, the cross platform libraries do not support WPF. This means that it is now difficult to find the NuGet package which works with WPF.
不幸的是,微软将RX v2.2.5退市,取而代之的是完全跨平台的RX v3.1.0。但是,跨平台库不支持WPF。这意味着现在很难找到使用WPF的NuGet包。
To work around this, if you are using WPF
+ .NET 4.5
, install any NuGet package with a dependency on RX-XAML
. For example, reactiveui-blend
depends on RX-XAML v2.2.5
, so this will now work:
要解决这个问题,如果您正在使用WPF + . net 4.5,请安装任何依赖于RX-XAML的NuGet包。例如,reactiveui-blend依赖于RX-XAML v2.2.5,因此现在可以工作了:
setClipboard.ObserveOnDispatcher().Subscribe(o =>
{
...
});