sábado, 26 de marzo de 2011

Suspend y Resume obsoletos. Cómo resolver el problema

ANTES:

private Thread myThread;

private void WorkerThread()
{
myThread
= Thread.CurrentThread;
while (true)
{
myThread
.Suspend();
//Ejecutar tareas
}
}

public void StartWorking()
{
myThread
.Resume();
}


***************************************

AHORA:



...

private static EventWaitHandle wh;

...

wh = new EventWaitHandle(false,EventResetMode.AutoReset);

...

private
void WorkerThread()
{


while(true)
{
wh.WaitOne();

//Ejecutar tareas
}
}

public void StartWorking()
{
wh.Set();

}

No hay comentarios:

Publicar un comentario