Search code examples
c#multithreadingstatusstriptoolstripstatuslabel

Updating toolStripStatusLabel immediately


I have a WinForms program that has a button, a statusStrip, and a toolStripStatusLabel in that statusStrip. If I click the button and this runs:

private void button1_Click(object sender, EventArgs e)
{
    toolStripStatusLabel1.Text = "Test";

    System.Threading.Thread.Sleep(5000);
}

Then the toolStripStatusLabel's text doesn't update until after the thread is done sleeping. How do I get it to update immediately, then sleep the thread?


Solution

  • As P. Kouvarakis said, the solution was this:

    toolStripStatusLabel1.Text = "Test";
    statusStrip1.Update();