Is it possible to safely exchange this "status" between two threads?
private bool status = false; private void uiNewThread_bootloaderStartIdSetupAuto() { while (status) ; }
Below is a new thread that will be launched from the user interface below:
private void uiBtnBootloaderStartIdSetupAuto_Click(object sender, EventArgs e) { if (MessageBox.Show("ID will be setup starting from 1 to 16. \n\nAfter pressing 'YES', press the orange button one-by-one on the nodes.\nThe first pressed node will have number 1, the next number 2, and so on... \n\nWhen done, hit DONE button.", "ID setup", MessageBoxButtons.YesNo) == DialogResult.Yes) { status = true; Thread transmitConfig = new Thread(new ThreadStart(uiNewThread_bootloaderStartIdSetupAuto)); //close port in new thread to avoid transmitConfig.Start(); } else { Log(LogMsgType.Normal, "User cancelled"); status = false; } }
source share