Status Message

  • Thread starter Thread starter Davy
  • Start date Start date
D

Davy

I am trying to display to the user of this program that something is
actually happening, and the program is not frozen. However, in the
following button click, the only message that appears is the last one.
Thanks ahead for any help!

private void button1_Click(object sender, System.EventArgs e)
{
lblStatus.Text = "Processing Images";
generateImages();
generateHTML();
lblStatus.Text = "Processing Complete";
}
 
Changes happen to the visible appearance based on two things, the state of the window or one of its children changing and then it redrawing itself via a paint message. The second is important because it means the UI thread has to be free to process the message queue for the change to be seen. In your code your button handler is hogging the UI thread and so the window can't repaint itself. You need to perform generateImages and generateHTML on a background thread and have the "Processing Complete" update performed when those methods have finished. You do this by using the lblStatus.BeginInvoke method passing it a method (via a delegate) to execute on the UI thread to perform the UI update. You need to do the last bit because only the UI thread is allowed actually touch the UI.

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<[email protected]>

I am trying to display to the user of this program that something is
actually happening, and the program is not frozen. However, in the
following button click, the only message that appears is the last one.
Thanks ahead for any help!

private void button1_Click(object sender, System.EventArgs e)
{
lblStatus.Text = "Processing Images";
generateImages();
generateHTML();
lblStatus.Text = "Processing Complete";
}

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.771 / Virus Database: 518 - Release Date: 28/09/2004



[microsoft.public.dotnet.languages.csharp]
 
Back
Top