我的表单有200多个控件! 加载表单并绑定控件大约需要7秒钟.
My form has over 200 control(s)! It takes about 7 seconds to load the form and bind the controls.
我已经使用一些性能分析器跟踪了该应用程序,但是除了构造函数的形式外,我没有找到任何带有HOT标志的东西.
I've traced the application with some performance profilers , but I didn't find anything with HOT flag except the constructor's of form.
我想知道是否可以像backgroundWorker(multithreading)一样调用 InitializeComponent 方法!
I would like to know that is it possible to call InitializeComponent method with sth like backgroundWorker (multithreading) !?
推荐答案否,线程化对您没有帮助.需要在UI线程上创建控件,以使应用程序完全正常工作.
No, threading will not help you. The controls need to get created on the UI thread for the application to work at all.
唯一合理的方法是查看创建表单时是否真的需要创建 all 200个控件,或者是否可以按需加载它们.
The only reasonable way would be to look into whether you really need to create all 200 controls when the form is created, or if you can perhaps have them load "on demand".
在不了解您的应用程序的情况下,不可能给出更具体的指导,但是也许您遇到的情况是并非同时使用所有控件,而是存在某种分页.如果是这种情况,则可以将每个页面"设置为一个用户控件,以便您可以根据需要加载和卸载页面.
Without knowing your application it's impossible to give more concrete guidance, but perhaps you have a situation where not all controls are in use at the same time, but rather that there is some sort of paging. If that is the case, each "page" could perhaps be made into a user control, so that you can load and unload pages as they are needed.
更多推荐
加载具有200多个控件的Windows窗体
发布评论