private void button2_Click(object sender, EventArgs e)
{
Thread thread = new Thread(P);
thread.Start();
}
private void P()
{
for (int i = 0; i < 100; i += 10)
{
Thread.Sleep(1000);
H(i);
}
}
private void H(int i)
{
{
if (this.InvokeRequired)
{
Action<int> action = new Action<int>(H);
this.Invoke(action, i);
}
else
{
progressBar1.Value = i;
}
};
}