Thread.Join UI block in WPF

后端 未结 2 1663
傲寒
傲寒 2021-01-16 05:00

I created a custom MessageWindow in order to get rid of the old one and put my own style on it...

My problem is when I for example click a button to ope

相关标签:
2条回答
  • 2021-01-16 05:40

    You shouldn't create a new thread for the other window. When using WPF, all UI should run on the same thread.

    Create new threads when you want to do something that is unrelated to UI and don't want to block the UI.

    0 讨论(0)
  • 2021-01-16 05:52

    If you want to prevent the user from interacting with the main window while a MessageWindow is visible, simply set the Owner of the MessageWindow to your application's main window. Then call ShowDialog() from the UI thread, and the behavior should be comparable to if you called MessageBox.Show().

    Do not use a separate thread or attempt to manually block the message pump.

    0 讨论(0)
提交回复
热议问题