WPF / Winforms Hybrid App Questions

We’re transitioning from a Winform desktop app to a WPF one. The approach we took was to progressively re-write the Winform app in WPF. We started out by writing a WPF UI library that gets referenced by the Winform main app. Then the new WPF look and feel UIs would be displayed by instantiating WPF UIs from the library mentioned above. As a hybrid app, we’re dealing with the Winform-WPF interop issues. So here are two questions about a few problems we seem to be having:

<!--[if !supportLists]-->1)<!--[endif]-->1) The old (Winform app) did all the UI access from different threads by using the typical Invoke/begin invoke on the UI items (when needed ). Now that we are introducing WPF Uis in the there, we ended up instantiating and showing WPF Uis inside the code that gets invoked on the Winform UI thread. It seems to work, but we’re getting some strange exceptions in some cases. I think this is wrong as WPF has its own message loop (which we’re not running), and running WPF UIs on the Winform message pump seems incorrect.Is this a problem really? Will .NET figure it out?

<!--[if !supportLists]-->2)<!--[endif]-->2) We implemented our own MessageBox-like functionality in WPF. In other words, we have our own XXXMessageBox.Show(…) methods like the ones in Winforms. In doing so, sometimes a call to the XXXMessageBox.Show() needs be made from a non-UI thread. As the Show() method is a static, we have no way to get a dispatcher from a UI. I noticed that the Application class (in WPF) provides a global property for the Dispatcher. But this property returns null in our case as our desktop app is running the Winforms message loop only (via Applicarion.Run(…)). What do we doin this case? Should we call Dispatcher.Run() too?

as

ThThanks a lot.

[2490 byte] By [UIFreak] at [2008-1-7]