I have this code:
for(int k = 0; k<11; k++)
{
pBar.Maximum = 10;
pBar.Value = k;
if (pBar.Maximum == k)
pBar.Value = 0;
}
First: there is no any reason to assign pBar.Maximum on every interarion.
Just do:
pBar.Maximum = 10;
for(int k = 0; k<11; k++)
{
pBar.Value = k;
if (pBar.Maximum == k)
pBar.Value = 0;
}
Second: your code result in blocking iteration. There is no way it could ever behave correctly. Use multi-threading and change the progress value based on some event,tick whatever, not in loop, as it's done here.