この「ステータス」オブジェクトを 2 つのスレッド間で安全に共有できますか?
private bool status = false;
private void uiNewThread_bootloaderStartIdSetupAuto()
{
while (status)
;
}
上は、下の UI から起動される新しいスレッドです。
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;
}
}