We have recently ported the system from RX 1.11111 to RX 2.0 and discovered this problem. We use an EventLoopScheduler for ObserveOn like this:
IDisposable s
Just noticed this question as a link to this one: Reactive Rx 2.0 EventLoopScheduler ObjectDisposedException after dispose
Shall repost here what I did there - I'm not aware of any way to "flush" the scheduler, but you can wrap/handle the inevitable "object disposed" exception this way:
EventLoopScheduler scheduler = new EventLoopScheduler();
var wrappedScheduler = scheduler.Catch((ex) =>
{
Console.WriteLine("Got an exception:" + ex.ToString());
return true;
});
for (int i = 0; i < 100; ++i)
{
var handle = Observable.Interval(TimeSpan.FromMilliseconds(1))
.ObserveOn(wrappedScheduler)
.Subscribe(Observer.Create((x) => Thread.Sleep(1000)));
handles.Add(handle);
}