Click here to Skip to main content
15,880,469 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai all,

I have some code in "FirstForm" a Form like this:
C#
MyForm obj=new  MyForm();
obj.Show();

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..
Posted
Updated 27-Oct-11 2:06am
v3

Move the code from Loading into a BackgroundWorker thread[^] if you can. If not, try moving it to the Shown event - that may help.
 
Share this answer
 
Comments
version_2.0 28-Oct-11 0:25am    
thanks..
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900