I couldn't find an answer for this:
"Cross-thread operation not valid: Control 'progressBar1' accessed
from a thread other than the thread it was created on."
This is my code:
private void buttonStart_Click(object sender, EventArgs e)
{
ClassCopy cb = new ClassCopy();
cb.startCopy(textBoxSrc.Text, textBoxDest.Text, true);
th = new Thread(loading);
th.Start();
}
private loading()
{
for (int i = 0; i < 100; i++)
{
if (progressBar1.InvokeRequired)
progressBar1.Invoke(new Action(loading));
else
progressBar1.Value = i;
}
}
No comments:
Post a Comment