C# 终止线程问题
用线程启动检测串口(多个)
之后点击按钮结束串口读写
public bool shouldStop ;Thread com = new Thread(new ThreadStart(read));com.IsBackground = true;if(btnXX.Text=="xxx"){shouldStop=false; comRW.Start(); }else if(btnXX.Text=="yyy"){ while (!comRW.IsAlive) { Thread.Sleep(100); shouldStop = true; com.Join(); }}private void readMessage(){ while(!shouldStop){ //要执行的内容}}