
20/03/2008, 08:40
|
 | Colaborador | | Fecha de Ingreso: septiembre-2007 Ubicación: San Francisco, United States
Mensajes: 3.858
Antigüedad: 17 años, 5 meses Puntos: 87 | |
Re: Ejecución de proceso en una hebra public partial class Form1 : Form
{
public delegate void MyDelegate(int dato); // Delegado que no recibe ni manda
public Form1()
{
InitializeComponent();
}
public void InsertarDatoAListBox(int dato)
{
listBox1.Items.Add(dato);
}
public void Rellena()
{
MyDelegate delegado = new MyDelegate(InsertarDatoAListBox);
for (int i = 0; i < 10000000; i++)
{
BeginInvoke(delegado, new object[] {i });
Thread.Sleep(2000);
}
}
private void button1_Click(object sender, EventArgs e)
{
Thread mythread = new Thread(new ThreadStart(Rellena));
mythread.Start();
}
}
Solo recuerda algo , matar al hilo si cierras la ventana si no cuando intente seguir funcionando el delegado te dira q no hay identificador de ventana definido |