Im running a c# code with background worker. Im impelmenting it by having a foreach loop and inside the loop im passing the foreach variable as parameter for the Backgroundworker. But the problem is that whenever i run the code only single random value, most probably the last row in the gridview is passed as parameter. The code is as here
foreach (DataGridViewRow row in dataGridView3.Rows)
{
BackgroundWorker worker = new BackgroundWorker();
worker.WorkerSupportsCancellation = true;
worker.DoWork += delegate
{
data = dataGridView3.Rows[row.Index].Cells[0].Value.ToString();
rowindex = row.Index;
data1 = ros[0].Cells[0].Value.ToString();
};
worker.RunWorkerAync();
}