5
He creado un botón combinado de inicio/detención para iniciar y detener un hilo.¿Iniciando un hilo detenido?
se ve así:
private void btStartStop_Click(object sender, EventArgs e)
{
if (btStartStop.Text.Equals("Start"))
{
btStartStop.Text = "Stop";
stopThread = false;
ThreadState ts = thread.ThreadState;
if (thread.ThreadState == ThreadState.Stopped)
thread = new Thread(DoWork);
thread.Start();
}
else
{
btStartStop.Text = "Start";
stopThread = true;
thread.Join();
}
}
puedo comprobar el threadstate como a mí y si se detiene init de nuevo? o es de otra manera, ya que no puedo iniciar un hilo si se detuvo?