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

Theme Manager wont work with 2 Main windows on different (STA) Threads #3872

Closed
johanneswanzek opened this issue Jul 6, 2020 · 3 comments · Fixed by #3873
Closed

Theme Manager wont work with 2 Main windows on different (STA) Threads #3872

johanneswanzek opened this issue Jul 6, 2020 · 3 comments · Fixed by #3873
Labels
Milestone

Comments

@johanneswanzek
Copy link

johanneswanzek commented Jul 6, 2020

I have a Prism Application with a Bootstrapper and App.MainWindow (MetroWindow) running on MainThread and a seperate Login Window (also MetroWindow) running on sperate STA Thread to keep the UI responsive while Bootstrapper is running.

When switching the Theme in any situation the Application throws an exception: "The calling thread cannot access this object because a different thread owns it."

image

image

My assumption is that static Implementation and Event subscription from MetroWindow causes the Metro Window to crash when it does not belong to the Mainthread.

Thanks in advance,
Johannes

@punker76
Copy link
Member

punker76 commented Jul 6, 2020

@johanneswanzek Please create and publish a sample app with your implementation of this situation. Thx!

@johanneswanzek
Copy link
Author

Hello @punker76 Thanks for the fast response! :)

Please find my little Demo attached. I tried to keep it as simple as possible.

MahAppsSTAThreadApp.zip

@punker76
Copy link
Member

punker76 commented Jul 7, 2020

@johanneswanzek Thank you for the sample! This helped me to find the problem. 👍

mahapps_thread_dialogs

@punker76 punker76 added the Bug label Jul 7, 2020
@punker76 punker76 added this to the 2.1.2 milestone Jul 7, 2020
punker76 added a commit that referenced this issue Jul 7, 2020
Fix ThemeManager changes not working with different (STA) threads
@punker76 punker76 modified the milestones: 2.1.2, 2.2.0 Jul 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants