C#中方法调用的帮助 [英] help for method calling in C#

查看:53
本文介绍了C#中方法调用的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在"FirstForm"这样的表单中有一些代码:

Hai all,

I have some code in "FirstForm" a Form like this:

MyForm obj=new  MyForm();
obj.Show();


但是在MyForm的加载事件中,我已经写了一些大代码行(我无法避免).

由于此MyForm加载缓慢,并且当时我在FirstForm中无法执行任何操作..(这并不意味着我的操作系统变得无响应,我的操作系统正在完美响应,但我的FirstForm却变为无响应状态)

我需要的是..我想以让它加载"的方式加载MyForm ..但我不希望FirstForm在一段时间内不响应..


请帮帮我..

在此先感谢..


But in the load event of MyForm i have written some large lines of codes(I cant avoid that).

Because of this MyForm is loading slowly, and I cant do nothing at that time in FirstForm for some time..(It doesn''t mean that my OS becoming notresponding, My Os is responding perfectly,but my FirstForm is becoming Notresponding state)

What i need is.. I want load MyForm.. in a way that "Let it Load" but i dont Want FirstForm become NotResponding for some time..


Please Help me..

Thanks in advance..

推荐答案

将代码从加载到 ^ ]).如果不是,请尝试将其移至Shown事件-这可能会有所帮助.
Move the code from Loading into a BackgroundWorker thread[^] if you can. If not, try moving it to the Shown event - that may help.


要了解,您称为"FirstForm"的主窗体将启动,该窗体立即创建一个MyForm实例,其中包含大量的初始化代码使您的应用程序启动变慢.

第一个问题是为什么要使用MyForm?您不能使用主窗体还是将MyForm用作主窗体?

您可以将所需的处理移至后台线程,然后在处理完成后显示表单.
To understand, your main form, which you call "FirstForm", starts which immediately creates an instance of MyForm which contains a large amount of initialization code that is slowing your application startup.

The first question would be why have MyForm? Can''t you either use the main form or use MyForm as the main?

You can move the required processing to a background thread, then display the form when the processing is complete.


这篇关于C#中方法调用的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆