1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
private void ThreadActions(object sender, System.EventArgs e)
{
if (t != null)
{
if (t.ThreadState == ThreadState.Running)
{
mre.Reset();
this.button_ThreadActions.Text = "Resume Thread";
label_killThread.Text = " --> kill the Thread ?";
groupBox4.Controls.Add(this.button_killThread);
}
else
{
mre.Set();
this.button_ThreadActions.Text = "Suspend Thread";
label_killThread.Text = "";
groupBox4.Controls.Remove(this.button_killThread);
}
}
}
private void KillThread(object sender, System.EventArgs e)
{
if (t != null)
{
while (t.ThreadState != ThreadState.WaitSleepJoin) ;
t.Abort();
}
threadRunning = false;
} |