日期:2014-05-18 浏览次数:21025 次
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)
{
//要执行的内容
}
}