-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Running Window in another Thread results in a crash #4072
Comments
Holy Shit! That's exactly my problem. A minimum crashing example from me would be something like this:
Edit2: Yes, a Downgrade to 2.4.3 circumvents the aforementioned crash. |
It's possible something did change from 2.4.3 to 2.4.4, but this is pretty standard WPF behavior. WPF requires you to be on the dispatcher thread when doing any UI actions. What you guys are doing with Dispatcher is a bit confusing to me, @Jan18101997's dispatcher code wouldn't be doing anything, as the dispatcher isn't being used in any way. @chei-de's Dispatcher.Run() code really does nothing in the context you're using it, host.Show would be causing the exception before you even hit that line of code anyway. My guess would be that there used to be some sort of "ensure on dispatch thread" code in MetroWindow.Show() that was either taken out or broken in the 2.4.4 release. I'm pretty certain if you (@chei-de) wrap host.Show() in Dispatcher.BeginInvoke, the crash won't occur. |
Dispatcher.run starts a new dispatcher inside a new thread. a change in 2.4.4 broke this. As far as I understand the code at
Access application.current.... but in this chase the main application instance is running in a different thread and will result in a crash. |
Wow, I'm embarrassed to say I never knew this was possible in WPF, I thought you could only have a single Dispatcher per application. Thank you for the info! |
I'm getting this exact error. My app used to work before however after upgrading to 2.4.4 this happened (except I upgraded from 1.6.0). I guess I'll downgrade to 2.4.3 as mentioned above. |
I've created a pull request for this issue but it was not accepted yet. If you are upgrading from 1.x make sure to follow there upgrade guide. It's possible, that you have to change some resources as well. Downgrading to 2.4.3 fixed the issue for me. |
After updating to 2.4.4 form 2.4.3 following code stopped working:
Running this results in a InvalidOperationException at
Due to some complex layouts I'm forced to run it in a different Thread. Otherwise all Windows are blocked white WPF initialises the other Window.
The text was updated successfully, but these errors were encountered: