Hi, I have a C# application that creates and populates an Excel file. This process is initiated by clicking a button and takes a few seconds.
I want to display a message "Please wait..." until the Excel file is created and populated.
So I have in the code something like this:
private void btnUpdateA_Click(object sender, System.EventArgs e)
lblWait.Visible = true;
lblWait.Text = "Please Wait...";
btnNext.Enabled = false;
oXL = new Excel.Application();
//Get a new workbook.
oWB = (Excel._Workbook)(oXL.Workbooks.Add( Missing.Value ));
oSheetP = (Excel._Worksheet)oWB.Worksheets;
. . . . . . . . . . . . . . . . . .
// and after the file is populated
lblWait.Visible = false;
btnNext.Enabled = true;
The Excel file is created and populated, but the label remains invisible all the time.
The btnNext button (see code) becomes enabled when the process is complete so I can see the start and end of the process.
But the label lblWait remains invisible.
Please note that if I place a message box (MessageBox.Show ("Clicked");) after the statement (lblWait.Visible = true;), then the label becomes visible until the file is created.
I tried to replace the message box statement by some time consuming code (Thread.Sleep(1000);) but that did not work as well.
Is there some threading involved that prevents the label from becoming visible and how can I make the label visible in this case?