我们最近将系统从RX 1.11111移植到RX 2.0并发现了这个问题.我们对ObserveOn使用EventLoopScheduler,如下所示:
IDisposable subscription = someSubject
.ObserveOn(m_eventLoopScheduler)
.SomeMoreRXFunctions()
.Subscribe((something)=>something)
Run Code Online (Sandbox Code Playgroud)
调度程序位于应用程序出口(m_eventLoopScheduler.Dispose)上.在此之前,我们处理observable(subscription.Dispose)的所有订阅.
尽管如此,我们正在进入ObjectDisposedException内部EventLoopScheduler.Schedule.捕获该异常是不可能的,因为它起源于RX线程.这几乎就像Dispose没有摆脱某些队列中的所有项目.
我们试图删除调用,EventLoopScheduler.Dispose异常消失了.但是,SomeMoreRXFunctions()尽管所有订阅都已被处理,但代码仍执行了大约10次.
有没有其他方法可以正确关闭EventLoopScheduler?