hI Friends,can anyone tell me ? . Why i am getting the following error when i try run the following code ?.it says the following
Cross-thread operation not valid: Control 'label1' accessed from a thread other than the thread it was created on.
Cross-thread operation not valid: Control 'label1' accessed from a thread other than the thread it was created on.
Code:
for (int i = 0; i < 10; i++) {
label1.Text = i.ToString();
System.Threading.Thread.Sleep(500);
backgroundWorker1.ReportProgress(i);
label1.Refresh();
}