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

  • Thread starter Thread starter Curious
  • Start date Start date
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!
 
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,
 
Back
Top