Switch from "loading..." message to file name

C

Curious

There's a problem with what is displayed on a tab in my UI. At first,
it's a message, "loading...". Then it should be replaced with the
actual file name on the tab.

Now the issue is that it takes a long time before the message
"loading..." is replaced by file name. In my debugger, the switch
between "loading..." and file name happens AFTER the last line of code
below:

void LoadReportFilesWorker_RunWorkerCompleted(object sender,
RunWorkerCompletedEventArgs e)
{
this.tabControl.SuspendLayout();

foreach(TabPage lPage in mDynamicPages)
{
this.tabControl.TabPages.Add(lPage);
}
this.tabControl.TabPages.Remove(mLoadingPage);

this.tabControl.ResumeLayout(true);
}

When I hit F10 at "}", "loading..." is replaced by the file name.
Anyone can tell me why it takes long time to get the file name
displayed? Thanks!
 
G

Guest

It might be that the UI thread must wait until it can actually refresh the
display.

Try to use:
Application.DoEvents();
right after you change the "loading..." caption to the actual filename.


HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top