Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Element host loading time issue with winforms

I have an element host with 3 WPF controls. I am placing the element host on a winform. When my application is coming up, the element host is taking few seconds and the winform is getting displayed as a blank screen.

How to fix this? Any ideas are appreciated. Basically, I don't want to display the blank screen as it looks ugly when the application is coming up.

like image 972
Vinjamuri Avatar asked Nov 05 '22 12:11

Vinjamuri


2 Answers

This strikes me as really strange. I've used an ElementHost before and didn't notice any serious delay in loading child controls.

It would helpful if you could try isolating the problem by replacing your controls with just a single, plain TextBox control. How long does it take to load, then?

My suspicion is that there's actually something in your control logic that is taking a long time to complete and delaying the control loading. If you can figure out what that is and speed it up or make the processing asynchronous (consider using Reactive Extensions) then you'll at least get rid of the black screen. A profiler (Visual Studio or ANTS) would be a huge help in narrowing that down.

like image 150
hemp Avatar answered Nov 15 '22 05:11

hemp


You can speed up your loading time by loading model window load & close your application start up(This is only a trick :))

Simply create new window with one or two element hosts and add their child wpf controls. no need to implement any logic or set any properties, just add child controls.

Then when application start up load your model window and close (set load location away from screen boundary). (if you want you can use your original window also. )

then your window will open normally.

like image 26
Sampath Avatar answered Nov 15 '22 06:11

Sampath