// Método a enviar al Hilo. public void Metodo() { int num = 10; dele elDelegado = new dele(Mover); if (Thread.CurrentThread.Name.Equals("caballo0")) { elDelegado.Invoke(pbCaballo1, pbCaballo1.Location.Y, num); cola.Enqueue("Caballo 1"); } else if (Thread.CurrentThread.Name.Equals("caballo1")) { elDelegado.Invoke(pbCaballo2, pbCaballo2.Location.Y, num); cola.Enqueue("Caballo 2"); } else if (Thread.CurrentThread.Name.Equals("caballo2")) { elDelegado.Invoke(pbCaballo3, pbCaballo3.Location.Y, num); cola.Enqueue("Caballo 3"); } else if (Thread.CurrentThread.Name.Equals("caballo3")) { elDelegado.Invoke(pbCaballo4, pbCaballo4.Location.Y, num); cola.Enqueue("Caballo 4"); } else if (Thread.CurrentThread.Name.Equals("caballo4")) { elDelegado.Invoke(pbCaballo5, pbCaballo5.Location.Y, num); cola.Enqueue("Caballo 5"); } else { // No hay más hilos. } string[] ca = cola.ToArray(); foreach (var i in ca) { pos = lvLugares.Items.Add(i); } cola.Clear(); this.btnReiniciar.Enabled = true; }
// Método a enviar al Hilo. public void Metodo() { int num = 10; dele elDelegado = new dele(Mover); if (Thread.CurrentThread.Name.Equals("Shape0")) { elDelegado.Invoke(num); } else if (Thread.CurrentThread.Name.Equals("Shape1")) { elDelegado.Invoke(num); } else if (Thread.CurrentThread.Name.Equals("Shape2")) { elDelegado.Invoke(num); } else if (Thread.CurrentThread.Name.Equals("Shape3")) { elDelegado.Invoke(num); } else if (Thread.CurrentThread.Name.Equals("Shape4")) { elDelegado.Invoke(num); } else if (Thread.CurrentThread.Name.Equals("Shape5")) { elDelegado.Invoke(num); } else { // No hay más hilos. } }