Click here to Skip to main content
15,886,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm writing a simple app to copy files from one location to another. It consists of only two forms:

The main form where the user selects source and destination and hits a button to begin the copy process

A pop-up form (frmProgress) with a progressbar, ok, and cancel button.

When the user hits the copy button on the main form the following code is invoked to call the pop-up form and begin the copy process. The .show() for the second form is invoked in the constructor. The .start() function of the pop-up form does the actual copying.

The problem I'm having is that the form comes up but only partially displays its elements... that is, the okay and cancel buttons are not showing and in their place is just grey space. At the end of the copy they finally appear. Why is this? It's as if the form starts to display, stops to start doing the copying, and then finishes displaying.

What I don't get is I called the .show() first, in the contstuctor, and then I called the .start()... why does the form not display everything first and do the copying? Also worth noting, is that I tried to do the .show() in a seperate thread by to no avail. Please help.

MIDL
frmprog = new frmProgress(sourceControl.txtDestinationPath.Text, destinations);
//frmprog.Visible = true;
frmprog.start();
Posted
Comments
Sergey Alexandrovich Kryukov 11-Feb-11 22:01pm    
It can happen, hard to say without looking at your code...

1 solution

When your form's doing work, it blocks the UI thread and this is why your form does not paint properly until the work's done. Look up BackgroundWorker on MSDN and you'll see how you can put the copy task into the worker thread and free up your UI thread.
 
Share this answer
 
v2
Comments
Albin Abel 11-Feb-11 23:01pm    
good suggestion

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