I\'m using Rx 2.0\'s EventLoopScheduler to queue up / serialize work. When I need to dispose the scheduler, if there is remaining work, I will receive an unhandled ObjectDis
Actually, there is a simple way to flush the EventLoopScheduler
queue before disposing. First, make sure that all subscriptions that are adding actions to the queue are disposed, so that nothing else can be added.
Then, simply schedule the dispose of the scheduler itself:
scheduler.Schedule(() =>
{
// cleanup code: dispose of other stuff here
scheduler.Dispose();
});
This last scheduled action is ensured to run after all other pending actions have run and shutsdown the thread.