Código
if (backgroundWorker1.CancellationPending == true) { e.Cancel = true; return; }
quedando asi:
Código
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { while (true) { imgId = rnd.Next(minValue: 0, maxValue: 3); switch (imgId) { case 0: img = Traga_monedas_frutas.Properties.Resources.Manzana; break; case 1: img = Traga_monedas_frutas.Properties.Resources.Pina; break; case 2: img = Traga_monedas_frutas.Properties.Resources.Cereza; break; default: img = Traga_monedas_frutas.Properties.Resources.Banana; break; } if (backgroundWorker1.CancellationPending == true) { e.Cancel = true; return; } } }
y si funciona!....
gracias por tu ayuda me ha servido de mucho