Sam

Sam

  • NA
  • 166
  • 0

Text box text update

Oct 31 2014 11:05 AM
To solve a more complex c# issue in VS2010 Win7, I devised a simple test app:
I have a winform with a textbox and a button.
I have a loop that is supposed to write numbers into the text box.
When I run the program (hit the button), no numbers are being written to the textbox until the 10 seconds elapse, reaching the end of the loop, when it writes 99.
What is wrong in this seemingly simple function? I probably overlook something!?
Thanks!

int index;
        private void button2_Click(object sender, EventArgs e)
        {
            for (index = 0; index < 100; index++)
            {
                textboxOut.Text = index.ToString();
                Thread.Sleep(100);
            }
        }

Answers (4)