|
this's the error when I run the program "Cross-thread operation not valid: Control 'listBox1' accessed from a thread other than the thread it was created on."
please help me
this's my code, it's simple
private void button1_Click(object sender, EventArgs e)
{
backgroundWorker2.RunWorkerAsync();
}
public void additem(int i)
{
listBox1.Items.Add(i);
}
private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
{
for (int i = 0; i < 10; i++)
{
additem(i);
Thread.Sleep(500);
}
}
|
|
|
|
|
Hi,
I can see similar thread Here[^]
Please let me know if it not works...
Thanks
-Amit Gajjar (MinterProject)
|
|
|
|
|
hi,
Thank you very much for your help .
I have done, i using "invoke and delegate"
Invoke(new MethodInvoker(delegate {
listBox1.Items.Add(value);
}));
|
|
|
|
|
Nice...
Thanks
-Amit Gajjar (MinterProject)
|
|
|
|
|