I want in this code in the any step label show the Number of that step. In the my code just show last number in the label!
i can do it with doevent() but I think at times face with problem
enter code here
private void button1_Click(object sender, EventArgs e)
{
int i = 0;
while (i<100)
{
i++;
label1.Text = string.Format("Step is :{0}", i);
Application.DoEvents();
label1.Inval开发者_如何学Goidate();
System.Threading.Thread.Sleep(1000);
}
}
Assuming you want the counter to update the label while still performing the actions of Application.DoEvents(), you will likely need to run the tasks on a separate thread, else the code will execute and return the result after the thread has been released back to the application.
精彩评论