private void Button_Click(object sender, RoutedEventArgs e) { try { if (isCrt310 == false) { return; } if (crt310Thread != null) { crt310Thread.Abort(); crt310Thread.DisableComObjectEagerCleanup(); crt310Thread = null; } crt310Thread = new Thread(delegate() { isCrt310 = false; showInfo("正在检测,请稍后..."); //银联读卡器 Thread.Sleep(1000); string str = DeviceState.SendCRT310State(); if (str == null) { setTextBlockText(crt310lbl, "正常"); } else { setTextBlockText(crt310lbl, "异常:" + str.Remove(0, 2) + " " + ExceptionInfo(str)); } showInfo("设备状态"); isCrt310 = true; }); crt310Thread.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("设备检测异常"); } }