The problem is that you are running that code on the UI thread - because if you weren't you would get an "cross threading error" - which means that the code that is responsible for updating your display cannot run until that method exits. Because it doesn't exit but goes to sleep instead, it isn't running to update the display, so you never see the number change.
There are ways to get what you want - i.e. the label changing every second - but exactly how you do it depends on the environment you are working in: a WinForms solution would be different to a website based solution for example. And there are different ways to do it, depending on how complicated you can cope with, and how much bad code you can tolerate.
I'm going to assume a WinForms solution, and since you are a beginner, I'm going to ignore the "bad code" option as well, for reasons it would take far too long to explain.
That leave you two options:
1) Multi-threading.
2) Timer.
The threading option gets very complicated, because you need to create a new thread, and then pass some code back to the original thread to actually change the label (or you get the cross threading error I mentioned earlier) so I'm going to put that on the shelf as well, and explain the simplest "proper" way to do it.
Delete your loop.
Create a class level integer, called
count
.
private int count = 0;
Add a Class level Timer instance, called
updateLabel
private System.Windows.Forms.Timer updateLabel = new System.Windows.Forms.Timer();
In your Click event, add this code:
updateLabel.Interval = 1000;
updateLabel.Tick += updateLabel_Tick;
updateLabel.Start();
Now add a handler for the Tick event:
void updateLabel_Tick(object sender, EventArgs e)
{
label1.Text = "Processing " + (++count).ToString();
}
Run your code.