Windows runtime WinRT中的RX线程问题

Windows runtime WinRT中的RX线程问题,windows-runtime,system.reactive,Windows Runtime,System.reactive,我有一些简单的代码: var timer = Observable.Timer(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(1)).Timestamp(); //timer.Subscribe(x => timerTb.Text = x.Value.ToString()); timer.Subscribe(x => Debug.WriteLine(x.Value)); 视图上有一个名为timerTb的文本框。我正试图让注释掉的

我有一些简单的代码:

var timer =  Observable.Timer(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(1)).Timestamp();

 //timer.Subscribe(x => timerTb.Text = x.Value.ToString());
 timer.Subscribe(x => Debug.WriteLine(x.Value));
视图上有一个名为timerTb的文本框。我正试图让注释掉的行工作,而不让它大声谈论编组问题

据我所知,我应该使用
timer.ObserveOnDispatcher().Subscribe(…
但我无权访问此方法,也无权访问引用“System.Reactive.Linq;”的CoreDispatchersScheduler Dispatite

我正在运行RX2.0.20304.0


有什么想法吗?

将计时器放在UI线程上:

Observable.Timer(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(1), CoreDispatcherScheduler.Instance)
    .Timestamp();

我设法使它工作起来

CoreDispatchersScheduler犯了一个愚蠢的新手错误:System.Reactive.Windows.Threading

一旦我引用了它,我就得到了ObserveOnDispatcher(),它就起作用了:

var timer = Observable.Timer(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(1)).Timestamp();

timer.ObserveOnDispatcher().Subscribe(x => timerTb.Text = x.Value.ToString());

当你使用Rx来运行基本上线程不安全的代码时,Rx的值会迅速消失。至少在文章中,没有理由不使用Dispatcher。我只是想在这个视频中重现38分钟内完成的一些事情: