private void Button_Click_1(object sender, RoutedEventArgs e) { try { if (isCrt603 == false) { return; } if (crt603Thread != null) { crt603Thread.Abort(); crt603Thread.DisableComObjectEagerCleanup(); crt603Thread = null; } crt603Thread = new Thread(delegate() { isCrt603 = false; showInfo("正在检测,请稍后..."); //公交读卡器 Thread.Sleep(1000); string str = DeviceState.SendCRT603State(); if (str == null) { setTextBlockText(crt603lbl, "正常"); } else { setTextBlockText(crt603lbl, "异常:" + str.Remove(0, 2) + " " + ExceptionInfo(str)); } showInfo("设备状态"); isCrt603 = true; }); crt603Thread.Start(); } catch (ThreadAbortException ae) { log.Write("error:" + ae.Message); } catch (Exception ex) { log.Write("error:" + ex.Message); } }
private void checkState() { try { string str = DeviceState.SendCRT310State(); if (str == null) { setTextBlockText(crt310lbl, "正常"); } else { setTextBlockText(crt310lbl, "异常:" + str.Remove(0, 2) + " " + ExceptionInfo(str)); } str = DeviceState.SendZT598State(); if (str == null) { setTextBlockText(zt598lbl, "正常"); } else { setTextBlockText(zt598lbl, "异常:" + str.Remove(0, 2) + " " + ExceptionInfo(str)); } str = DeviceState.SendPrintState(); if (str == null) { setTextBlockText(printlbl, "正常"); } else { setTextBlockText(printlbl, "异常:" + str.Remove(0, 2) + " " + ExceptionInfo(str)); } str = DeviceState.SendCJ201State(); if (str == null) { setTextBlockText(cj201lbl, "正常"); } else { setTextBlockText(cj201lbl, "异常:" + str.Remove(0, 2) + " " + ExceptionInfo(str)); } str = DeviceState.SendCRT603State(); if (str == null) { setTextBlockText(crt603lbl, "正常"); } else { setTextBlockText(crt603lbl, "异常:" + str.Remove(0, 2) + " " + ExceptionInfo(str)); } showInfo("设备状态"); } catch (Exception ex) { log.Write("error:设备检测异常:" + ex.Message); showInfo("设备检测异常"); } }