private void CloseScene() { try { AxAGI.STKX.AxAgUiAxVOCntrl crl3d = new AxAGI.STKX.AxAgUiAxVOCntrl(); AxAGI.STKX.AxAgUiAx2DCntrl crl2d = new AxAGI.STKX.AxAgUiAx2DCntrl(); crl3d.Dock = DockStyle.Fill; crl2d.Dock = DockStyle.Fill; tabPage1.Controls.Clear(); //清空3d场景 tabPage2.Controls.Clear(); //清空2d场景 axAgUiAxVOCntrl1.Dispose(); axAgUiAx2DCntrl1.Dispose(); tabPage1.Controls.Add(crl3d); tabPage2.Controls.Add(crl2d); axAgUiAxVOCntrl1 = crl3d; axAgUiAx2DCntrl1 = crl2d; Thread.Sleep(100); state.isSceneSetUp = false; //清空信息队列和建立链路的索引 this.Scenemana.msglist.Clear(); //this.index = 0; //覆盖性能相关的复原工作 covsetup = false; 信关站覆盖显示ToolStripMenuItem.Checked = false; //每次重启的时候强行终止所有的excel程序,防止下次出现错误 string res; CmdHelper.RunCmd("taskkill /f /im excel.exe", out res); //0810再次更改 this.Scenemana = new STKScenObjs(this); } catch { } }
public void ResetCloseScene() { //0725添加新的excel处理,上次的还有问题 string res; CmdHelper.RunCmd("taskkill /f /im excel.exe", out res); if (this.state.isSceneSetUp == false) //isScenesetup说明rdxml清理过 { if (root.CurrentScenario != null) //20150907 { state.isSceneSetUp = false; //STK仿真场景是否已建立 CloseScene(); } return; } DateTime start = DateTime.Now; //LogHelper.InfoLog("ResetCloseScene", "进入函数"); TimeSpan tSpan = DateTime.Now - start;//中间的时间差是执行Loghelper的时间 this.root.Pause(); this.Cursor = Cursors.WaitCursor; //RdXml if (this.RdXml.xmlReaderThread != null) { if ((this.RdXml.xmlReaderThread.ThreadState & System.Threading.ThreadState.Stopped) == System.Threading.ThreadState.Stopped) { //Application.DoEvents(); //LogHelper.InfoLog("xmlReaderThread", "已关闭"); } else { lock (this.RdXml.stopRead) { if (this.RdXml.isStopRead == false) //在主线程中修改使子线程自然退出 { this.RdXml.isStopRead = true; } } start = DateTime.Now; while (true) { lock (this.RdXml.stopRead) { //Thread对象的ThreadState属性提供一个由ThreadState定义的位掩码,它指示线程的当前状态。一个线程至少总是处于ThreadState枚举中定义的一个可能状态,并且可以同时处于多个状态。 //1&1 =1; 结果是不变的才对. if (this.RdXml.isStopRead == false) { //Application.DoEvents(); break; } else if ((this.RdXml.xmlReaderThread.ThreadState & System.Threading.ThreadState.Stopped) == System.Threading.ThreadState.Stopped) { this.RdXml.isStopRead = false; //Application.DoEvents(); break; } else if ((this.RdXml.xmlReaderThread.ThreadState & System.Threading.ThreadState.WaitSleepJoin) == System.Threading.ThreadState.WaitSleepJoin) { try { this.RdXml.xmlReaderThread.Interrupt();//唤醒之并忽略报的异常 } catch (System.Threading.ThreadInterruptedException) { } } } Application.DoEvents(); //清空当前的消息队列,防止子线程发出的更新控件消息在控件回收后才处理 System.Threading.Thread.Sleep(100); //强制退出机制 tSpan = DateTime.Now - start; if (tSpan.TotalMinutes > 1) { WaitForm waitForm = new WaitForm(); waitForm.Text = "关闭场景超时,是否退出软件"; waitForm.ShowDialog(); if (waitForm.buttonClicked.Equals("buttonYes")) { Application.Exit(); } else { start = DateTime.Now; } } } } } Application.DoEvents(); if (this.state.isSceneSetUp == true) { state.isSceneSetUp = false;//STK仿真场景是否已建立 CloseScene(); } //STK仿真场景Lev1的全部obj,例如卫星、实体等 Scenemana.stkObjs.Clear(); Scenemana.sensorcolor_index = 0; Scenemana.all_path.Clear(); Scenemana.LineTargets.Clear(); this.RdXml.allPackets.Clear(); this.RdXml.sw.Reset(); try { //Other Form chartView.Dispose(); chartView = new ChartView(); chartView.Hide(); trafficView.Dispose(); trafficView = new TrafficView(); trafficView.Hide(); } catch { } System.Threading.Thread.Sleep(100); this.toolStripStatusLabel2.Text = "场景名"; this.toolStripStatusLabel4.Text = "未开始"; state.replayDataFaster = 1; toolStripStatusLabel5.Text = "x" + state.replayDataFaster.ToString(); this.Cursor = Cursors.Default; }