I'd like to run one function or both functions A and B at the same time depending if corresponding checkboxes c_A
and c_B
are chcecked or not. I'd also like to stop all (one or two) running functions by cliking stop button. I tried following code. It wokrs when only one chceck box is chcecked. When both chceckboxes are chcecked just function A runs. The running function doesn't stop when I press the stop button.
private void Start_Click(object sender, EventArgs e)
{
ThreadStart ts_A = delegate()
{
};
if (c_A.Checked)
{
t_A = new Thread(ts_A);
t_A.Start();
function_A();
}
ThreadStart ts_B = delegate()
{
};
if (c_B.Checked)
{
t_B = new Thread(ts_B);
t_B.Start();
function_B();
}
}
private void Stop_Click(object sender, EventArgs e)
{
t_A.Abort();
t_B.Abort();
}