Opening a WPF Window in another Thread from a Windows Forms App

后端 未结 3 889
日久生厌
日久生厌 2021-02-15 19:27

OK, I should start this off by saying I\'m not sure this is necessarily the right way to deal with this but...

Basically I have created a Window in WPF for displaying no

3条回答
  •  抹茶落季
    2021-02-15 19:49

    1. Is it possible to show this WPF in it's own thread?

    Absolutely. Just create a new STA thread and create and display your Window from it. I've used this technique for a splash screen because the main (UI) thread got really tied up doing other things. It was completely out of my control how much work was being done on the UI thread because of a 3rd party framework we were using.

    1. Why do I see some resources say that you should not show any UI in a separate thread?

    Possibly because of the extra complexity involved. If one of your Windows wants to pass data to another, you need to remember that they're executing on separate threads. Therefore, each should use its Dispatcher to marshal calls to the correct thread.

提交回复
热议问题