实战多线程交互

时间:2021-05-24 04:57:32   收藏:0   阅读:0

一段有问题的代码,大概20%的概率,bStartSend的值的改变没有被检查到

   //线程一直循环,等待消息
            while (true)
            {
                if (bStartSend)
                {
                    LogInfo("bStartSend=true");
                    StartMotor(ref ErrMsg, ref recvMsg, his.strCurrentCmd);

                }
                System.Threading.Thread.Sleep(100);
                Application.DoEvents();

            }

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!