this code keeps checking if a checkbox is checked and terminates the thread if it isn't.
Code:private void button1_Click(object sender, System.EventArgs e) { System.Diagnostics.Debug.WriteLine("startthread"); Thread t = new Thread(new ThreadStart(threader)); t.Start(); } private void threader() { Thread.Sleep(100); if (this.checkBox1.Checked) { threader(); } else { System.Diagnostics.Debug.WriteLine("stop"); } }




Reply With Quote