Ver Mensaje Individual
  #2 (permalink)  
Antiguo 13/11/2012, 07:08
Avatar de jhonwilliams
jhonwilliams
 
Fecha de Ingreso: marzo-2004
Ubicación: Copacabana - Colombia
Mensajes: 1.484
Antigüedad: 20 años, 2 meses
Puntos: 76
Respuesta: BackgroundWorker, c#, alternativa?

Hola,

Segun, lo que te entendi y lo que he usado NO debes tratar de deshacerte del BackgroundWorker, yo tambien lo e usado y para poder asignar el texto a tu TextBox dentro del While debes hacer mas o menos esto:

1. Creas un delegado
Código C#:
Ver original
  1. delegate void SetTextCallback(string text);

2. Creas el metodo que asigna el texto a tu TextBox

Código C#:
Ver original
  1. private void SetText(string mytexto)
  2.         {
  3.             // InvokeRequired required compares the thread ID of the
  4.             // calling thread to the thread ID of the creating thread.
  5.             // If these threads are different, it returns true.
  6.             if (this.InvokeRequired)
  7.             {
  8.                 SetTextCallback d = new SetTextCallback(SetText);
  9.                 this.Invoke(d, new object[] { mytexto});
  10.             }
  11.             else
  12.             {
  13.                 TuTextBox.Text =  mytexto;              
  14.             }            
  15.         }

3. En el evento ......_DoWork del BackGroundBroker que es donde me imagino que tenes el while debes hacer el llamado al metodo enviando el texto que quieres asignar.

Código C#:
Ver original
  1. SetText("127.0.0.1");

Pruebalo y me comentas como te fue.

Saludos
__________________
Si mi respuesta te ha ayudado, agradezco que me regales unos puntos de Karma XD.

"Una mujer sería encantadora si uno pudiera caer en sus brazos sin caer en sus manos." (Ambrose Bierce)