/**Measure UI thread function.*/ private void MeasureUIFunc() { //DEFINATION //bool isError; bool isDequeSuccess; //INIT //isError = false; isDequeSuccess = false; //PROCESSING init.handclasp_meet(); while (!GlobalQuit.Quit) { try { //if (measureUpdateList.Count != mapRowDataList.Count) //bindMeasureDrawEvent(); isDequeSuccess = measureQueue.Dequeue(ref measureQueueElement); if (isDequeSuccess) { //if receive the end atom of queue, just break and stop the thread. if (measureQueueElement.IsEnd == true) { break; } if (FormList.FormMeasurement == null) { continue; } if (!MainForm.IsToStop) { FormList.FormMeasurement.addPoints(measureQueueElement); //FormList.FormCalibrate.addPoints(measureQueueElement); } } else { StackTrace st = new StackTrace(new StackFrame(true)); LogHelper.WriteLog("MeasureUI thread timed out when Dequeue!", st); #if USE_WARNING MessageBox.Show("融合显示线程出队超时,请马上设置断点检查。位置:MeasureUIThread.MeasureUIFunc"); #endif status = ThreadCondition.error; //isError = true; } } catch (Exception e) { StackTrace st = new StackTrace(new StackFrame(true)); LogHelper.WriteLog(e, st); #if USE_WARNING MessageBox.Show("检测到异常,请马上设置断点检查。位置:AscanUIThread.AscanUIFunc"); #endif status = ThreadCondition.error; //isError = true; } } init.handclasp_force(); clean.handclasp_meet(); status = ThreadCondition.exit; }
/**Parse thread function.*/ private void parseFunc() { //DEFINATION bool isDequeSuccess; bool isParseSuccess; //bool isError; CaptureOutQueueElement outqueueElement; //A queue atom represent the end of the ascan queue. AscanQueueElement ascanEndElement; //A queue atom represent the end of the mergein queue. MergeInQueueElement mergeInEndElement; //INIT isDequeSuccess = false; isParseSuccess = false; //isError = false; outqueueElement = new CaptureOutQueueElement(); ascanEndElement = new AscanQueueElement(); ascanEndElement.IsEnd = true; mergeInEndElement = new MergeInQueueElement(); mergeInEndElement.IsEnd = true; //PROCESSING init.handclasp_meet(); while (!GlobalQuit.Quit) { try { isDequeSuccess = inputQueue.Dequeue(ref outqueueElement); if (isDequeSuccess) { //if receive the end atom of queue, just break and stop the thread. if (outqueueElement.IsEnd == true) { break; } // LogFile.write("开始分发"); isParseSuccess = parsePacket(outqueueElement.setPacket); // LogFile.write("分发结束"); if (!isParseSuccess) { StackTrace st = new StackTrace(new StackFrame(true)); LogHelper.WriteLog("The format of packet is wrong or ParseThread timed out when Enqueue!", st); #if USE_WARNING MessageBox.Show("分发线程获取的数据格式错误或入队失败,请马上设置断点检查。位置:ParseThread.parseFunc"); #endif status = ThreadCondition.error; //isError = true; } } else { StackTrace st = new StackTrace(new StackFrame(true)); LogHelper.WriteLog("ParseThread timed out when Dequeue!", st); #if USE_WARNING MessageBox.Show("分发线程出队超时,请马上设置断点检查。位置:ParseThread.parseFunc"); #endif status = ThreadCondition.error; // isError = true; } } catch (Exception e) { StackTrace st = new StackTrace(new StackFrame(true)); LogHelper.WriteLog(e, st); #if USE_WARNING MessageBox.Show("检测到异常,请马上设置断点检查。位置:ParseThread.parseFunc"); #endif status = ThreadCondition.error; //isError = true; } } init.handclasp_force(); //ascanQueue.EnqueueWithSemaphor(ascanEndElement); //mergeInQueue.EnqueueWithSemaphor(mergeInEndElement); clean.handclasp_meet(); status = ThreadCondition.exit; }