/// <summary> /// 初始化 /// </summary> private void Init() { if (_rr9.OpenComPort()) { _rr9.Change14443(); _rr9.StartHidListen(YingXinRr9_HidListen); TimingBegin(); } else { MessageBox.Show(@"设备异常!"); _rr9.CloseComPort(); Close(); } }
private void btnStart_Click(object sender, EventArgs e) { btnStart.Enabled = false; try { BeginInvoke(new MethodInvoker(() => { dgvAction.Rows.Clear(); })); if (_rr9.OpenComPort()) { _rr9.Change14443(); _rr9.StartHidListen(YingXinRr9_HidListen); btnEnd.Enabled = true; btnEnd.Focus(); TimingBegin(); } else { ResetAction(); MessageBox.Show(@"设备异常!"); BeginInvoke(new MethodInvoker(() => { btnStart.Focus(); })); } } catch (Exception ex) { ResetAction(); BeginInvoke(new MethodInvoker(() => { btnStart.Focus(); })); Logger.Error(ex); throw ex; } }