I have the following code:
IDisposable subscription = myObservable.Throttle(TimeSpan.FromMilliseconds(50), RxApp.MainThreadScheduler)
.Subscribe(_ => UpdateUi());
正如预期的那样,UpdateUi()
总是在主线程上执行。当我将代码更改为
IDisposable subscription = myObservable.Throttle(TimeSpan.FromMilliseconds(50))
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(_ => UpdateUi());
UpdateUI()
将在后台线程中执行。
为什么 Throttle(...).ObserveOn(scheduler)
不等同于 Throttle(..., scheduler)
?
MainThreadScheduler
出了问题(请参见https://dev59.com/iojca4cB1Zd3GeqPvlww#28827962)。 - larsmoa