热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

使用winforms的元素主机加载时间问题-Elementhostloadingtimeissuewithwinforms

Ihaveanelementhostwith3WPFcontrols.Iamplacingtheelementhostonawinform.Whenmyappl

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.

我有一个带有3个WPF控件的元素主机。我将元素主机放在winform上。当我的应用程序出现时,元素主机需要几秒钟,winform将显示​​为空白屏幕。

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.

如何解决这个问题?任何想法都表示赞赏。基本上,我不想显示空白屏幕,因为它在应用程序出现时看起来很难看。

2 个解决方案

#1


1  

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

这让我觉得非常奇怪。我之前使用过ElementHost,并没有注意到加载子控件有任何严重的延迟。

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?

如果你可以通过用一个简单的TextBox控件替换你的控件来尝试隔离问题会很有帮助。那么加载需要多长时间?

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.

我怀疑你的控制逻辑实际上有些东西需要很长时间才能完成并延迟控制加载。如果你能弄清楚它是什么并加速它或使处理异步(考虑使用Reactive Extensions)那么你至少会摆脱黑屏。分析器(Visual Studio或ANTS)将有助于缩小范围。

#2


1  

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.

只需使用一个或两个元素主机创建新窗口并添加其子wpf控件。无需实现任何逻辑或设置任何属性,只需添加子控件。

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.

然后你的窗口会正常打开。


推荐阅读
author-avatar
飘移zj_114
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有