我们使用的是.NET 3.5,并且已经开始使用反应式扩展。我们使用的是兼容.NET 3.5的system.Reactive (运行时版本:v2.0.50727)。
我正在尝试观察调度程序上的事件,因为我使用的是WPF控件(它是winforms shell,嵌入了WPF主机控件),但是我在调度程序类(system.reactive.concurrency.scheduler)上找不到该选项。看起来它是从.NET 4.0开始提供的。我的问题是,如何在.NET 3.5中实现这一点?请注意,调用发生在我的ViewModel中,而不是视图中。
代码:
this.ObservePropertyChanged(x => x.Queue)
//I cant find scheduler dispatcher option,
//there are other options such as current, imeediete, new etc.
.ObserveOn(Scheduler.Dispatcher)
.Subscribe(RefreshQueues);谢谢,
-Mike
发布于 2014-07-22 22:59:58
更新:基于Rx 2.2.4.0
当前已将WPF的DispatcherScheduler移入System.Reactive.Windows.Threading命名空间。
使用Nuget包,搜索Rx-WPF以下载包,并使用DispatcherScheduler.Current代替Scheduler.Dispatcher
发布于 2013-09-24 14:29:33
您应该能够使用http://www.nuget.org/packages/Rx-WinForms/的RX Winforms扩展库
this.ObservePropertyChanged(x => x.Queue)
.ObserveOn(control);或者如果你已经在正确的线程上。
this.ObservePropertyChanged(x => x.Queue)
.ObserveOn(SynchronizationContext.Current);发布于 2013-09-23 18:26:10
我认为你应该能够使用DispatcherScheduler.Current
https://stackoverflow.com/questions/18956633
复制相似问题