private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { capture capt = new capture(); BackgroundWorker worker = sender as BackgroundWorker; while (true) { if (worker.CancellationPending == true) { e.Cancel = true; break; } string s = ""; MethodInvoker combo = new MethodInvoker(() => { s = comboBox1.Text; }); comboBox1.Invoke(combo); capt.ipCapt(backgroundWorker1, checkBox2, s, button1); } }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { capture capt = new capture(); BackgroundWorker worker = sender as BackgroundWorker; while (true) { if (worker.CancellationPending == true) { e.Cancel = true; break; } string s=""; MethodInvoker combo = new MethodInvoker(() => { s = comboBox1.Text; }); comboBox1.Invoke(combo); capt.ipCapt(backgroundWorker1,checkBox2,s,button1); } }