views:

382

answers:

1

My project requires a background thread to initiate the creation of a WPF control hosted in a Winform. The creation of said control must be performed on the foreground thread, which is very costly and causes the UI to hang for 1 to 2.5 seconds (depending on whether this is the first time the control is created).

Are there any pre creation optimizations that can be done from a background thread to reduce the amount of work done by the UI thread?

Thanks Scott

A: 

I assume you use the ElementHost control to host the Wpf control in the winforms app? I think the overhead you're seeing is really necessary, as the device context the wpf elements are rendered on is marshalled to the winforms app and isn't living in a normal wpf application. My experience is that when you open a form with ElementHost on it, the second time is much faster, but of course it depends on what you're doing when it opens.

Frans Bouma