private void Button_Click_3(object sender, RoutedEventArgs e) { try { if (isZt598 == false) { return; } if (zt598Thread != null) { zt598Thread.Abort(); zt598Thread.DisableComObjectEagerCleanup(); zt598Thread = null; } zt598Thread = new Thread(delegate() { showInfo("正在检测,请稍后..."); //密码键盘 Thread.Sleep(1000); string str = DeviceState.SendZT598State(); if (str == null) { setTextBlockText(zt598lbl, "正常"); } else { setTextBlockText(zt598lbl, "异常:" + str.Remove(0, 2) + " " + ExceptionInfo(str)); } showInfo("设备状态"); }); zt598Thread.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("设备检测异常"); } }