新的Observer.Synchronize方法重载 [英] New Observer.Synchronize method overload

查看:80
本文介绍了新的Observer.Synchronize方法重载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到了新的观察者。同步方法重载:

I noticed new Observer. Synchronize method overload:

public static IObserver< T>同步< T>(IObserver< T>观察者,bool preventReentrancy)。

public static IObserver<T> Synchronize<T>(IObserver<T> observer, bool preventReentrancy).

它可以用于解决UI(Winforms / WFP)重入问题吗?

Can it be used to solve UI (Winforms/WFP) reentrance problem?

以前我使用source.ObserveOn(Scheduler.CurrentThread)来探索Scheduler.CurrentThread将事件排队等待处理的事实。

Previously I used source.ObserveOn(Scheduler.CurrentThread) exploring the fact that Scheduler.CurrentThread queues events for processing.

谢谢,

Dmitry Morozov

Dmitry Morozov

推荐答案

嗨德米特里,

我猜这是为了防止在观察者级别重新进入,而不会影响查询的语义。  某些复杂的查询会产生副作用的观察者,导致其他通知被推送给他们。 也许
这个重载提供了一种简单的方法来确保在不变量被破坏的情况下永远不会调用这种观察者,而不会触及查询。

I'd guess that it's meant to prevent reentry at the observer level without affecting the semantics of the query.  Some complex queries have side-effecting observers that cause additional notifications to be pushed to them.  Perhaps this overload provides a simple way to ensure that this kind of observer is never invoked while its invariants are broken, without touching the query.

>它可以用于解决UI(Winforms / WFP)重入问题吗?

"UI重入问题"是什么意思? 你能提供一个例子吗?

What do you mean by the "UI reentrance problem"?  Could you provide an example?

>以前我用过source.ObserveOn(Scheduler.CurrentThread) 

调用 ObserveOnDispatcher 而不是有什么问题?  ;用户界面已经提供了类似于
Scheduler.CurrentThread 的单线程排队机制。

What's wrong with calling ObserveOnDispatcher instead?  The UI already provides a single-threaded queueing mechanism similar to Scheduler.CurrentThread.

- Dave


这篇关于新的Observer.Synchronize方法重载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆