I have this code:
for(int k = 0; k<11; k++)
{
pBar.Maximum = 10;
pBar.Value = k;
if (pBar.Maximum == k)
pBar.Value = 0;
}
pBar.Maximum = 10;
int count = 0;
Timer timer = new Timer();
timer.Interval = 1000;
timer.Tick += (source, e) =>
{
pBar.Value = count;
if (pBar.Maximum == count)
{
pBar.Value = 0;
timer.Stop();
}
count++;
}
timer.Start();
Your problem is that you're using a loop. You need to use a timer so that the program has time to both perform the checks/assignments and update the screen.
The code replaces the for loop with a timer that calls the body of the loop. Since a timer does not have an index variable, it is initialized outside of the timer (count) and updated with each tick.