I have this error: Cross-thread operation not valid: "Control 'progressBar1' accessed from a thread other than the thread it was created on." I can't seem to figure out how to fix it.
private void button1_Click(object sender, EventArgs e)
{
this.panel1.Visible = false;
this.panel2.Visible = true;
new Thread(ProgressBAR).Start();
}
private void ProgressBAR()
{
Thread.Sleep(5);
for (int start = 0; start <= 100; start++)
{
this.progressBar1.Value = start;
Thread.Sleep(5);
}
}