简体   繁体   中英

Performance problems with displaying a WinForm dialog from WPF application

I am currently developing a WPF application that will utilize existing WinForm dialogs. I'm experiencing a long lag between the time I call ShowDialog() on a WinForm to the time it is displayed.

Even when reusing WinForm dialog objects the lag time is nearly as bad on the second hit. Meaning that the problem isn't in the constructor.

Does anybody have a work around to increase speed or know why the speed is so slow?

A quick test with a blank WPF app and an empty Forms dialog on my machine indicates that the biggest delay comes from the "open window" animation that Win7 performs. So I think that there is no inherent performance problem in WPF-Forms interop. Rather, we're probably missing a crucial implementation detail about your dialog.

  • What is your dialog doing in Load and FormShown events? Maybe you are using inheritance and the offending code is further down in the hierarchy?
  • Are you using a 3rd party component suite? These tend to do quite a bit of initialization on startup.

Your best bet probably is to use a profiler to find out where the time is actually spent.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM