private void CarBtn_Click(object sender, RoutedEventArgs e)
{
try
{
Thread thread = new Thread(() =>
{
// CarMoveCtrl car = DetectChainHelper.CarMove ;
mCar.Reset(true); //复位
mCar.MoveToIncubation(true); //到转盘入口处
mCar.PushCupAtIncubation(true); //小车在转盘处推入反应条
mCar.Reset(true); //小车复位
mCar.RemoveCupAtIncubation(true);//小车在转盘处移出反应条
mCar.MoveToDetection(true); //小车移动到检测箱进出口处
mCar.PushCupAtDetection(true); //小车在检测处推入一个反应条
mCar.RemoveCupAtDetection(true); //小车在检测箱处移出一个反应条
});
thread.Start();
}
catch (Exception ex)
{
MessageBox.Show("错误!" + ex.ToString());
}
}
在上面的代码中,当不添加线程时,窗体的线程被卡住(主要是因为复位或者其他命令需要等待返回值),加上线程就可以正常运行了,这是为什么?哪位大哥能帮小弟讲解下
https://www.cnblogs.com/jeffy-chang/p/7123792.html?utm_source=itdadao&utm_medium=referral