How to safely tell Rx IScheduler that it is time to exit #2195
Replies: 1 comment
-
In general, schedulers do not have any notion of shutting down. There is one exception: virtual schedulers, or more specifically anything that derives from The main reason we have this on virtual schedulers is that those are designed for use in test scenarios where we need to run to the end of all activity. (Basically, we to know that everything has finished before checking the results) We definitely need that in tests, because the intent of the tests is to verify that the correct behaviour occurs eventually, however long that may take, but we also want the tests to complete as soon as they have reached that 'eventually'. Draining the scheduler work queue is an efficient and reliable way to achieve this. Note that in this case, shutdown is not about enabling the scheduler to release any resources it has required. (So this is not like I don't think we've previously had any request for a similar 'drain' all outstanding work outside of testing scenarios. I can see one obvious problem with such a thing: if you use anything that schedules recurring work, then unless you've shut down all active subscriptions ( Is there an application problem you're looking to solve with this? Or are you just looking to understand how to shut down Rx 'properly' on exit? If it's the latter, then you don't need to do anything. |
Beta Was this translation helpful? Give feedback.
-
In a WPF application, or really any application, when it is time to exit, how do we tell
IScheduler
to exit? Is that by disposing of any observers currently in flight?Beta Was this translation helpful? Give feedback.
All reactions