Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let ReactiveUI RxApp handle multiple windows #2092

Closed
glennawatson opened this issue Jun 27, 2019 · 1 comment

Comments

Projects
None yet
1 participant
@glennawatson
Copy link
Contributor

commented Jun 27, 2019

On UWP each new window gets its own ui thread and the way WaitForDispatcherScheduler (which is the default scheduler for RxApp.MainThreadScheduler) works it is inherently only going to work on a single window app. As @anaisbetts put it in Slack, UWP UI thread situation is a "tire fire" and to quote "ReactiveUI is not designed to handle multiple window apps" - which essentially means no ProjectionManager, no ShareTarget, no ApplicationViewSwitcher, nothing multi-window. While I agree with the first part (and begrudgingly the second part), I am not so sure that RxUI shouldn't be considering these issues.

This can cause issues with RxApp.MainThreadScheduler, where each one of these windows runs its own dispatcher thread and is an “Application Single Threaded Apartment” (ASTA). Essentially the framework is blocking what it thinks is a potential deadlock. This particular exception is thrown when code running under one STA (1) calls out to another STA (2) and that STA (2) might have to re-enter STA (1) in order to do its work. The framework throws that exception at this point to try and stop you getting into a mess with deadlocks.

I am currently testing a scheduler that can handle multiple windows/dispatchers and will hopefully manage this as well, but we are still testing it and I'm not sure if I'll be able to block this exception yet (which would make my new scheduler useless... 👎).

Originally posted by @hinterlandsupplyco in #2034 (comment)

glennawatson added a commit that referenced this issue Jul 1, 2019

fix: Replace default `MainThreadScheduler` on UAP (#2100)
See #2092, #2032 for more info. This replaces the usage of
`WaitForDispatcherScheduler` and `CoreDispatcherScheduler` with a
scheduler that explicitly dispatches to the main app window regardless
of how many windows are created by the application.
@glennawatson

This comment has been minimized.

Copy link
Contributor Author

commented Jul 1, 2019

Fixed by #2100

madmonkey added a commit to madmonkey/ReactiveUI that referenced this issue Jul 12, 2019

fix: Replace default `MainThreadScheduler` on UAP (reactiveui#2100)
See reactiveui#2092, reactiveui#2032 for more info. This replaces the usage of
`WaitForDispatcherScheduler` and `CoreDispatcherScheduler` with a
scheduler that explicitly dispatches to the main app window regardless
of how many windows are created by the application.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.