/// <summary> /// 连接超时 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void timerSend_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { PortCommunication.timerSend.Enabled = false; if (conn.IsAlive) { conn.Abort(); } PortCommunication.closePort(); barEditItem3.Value = 0; if (dataerrer == true) { if (!issessce) { if (conCount < 1) { conCount++; Thread.Sleep(100); if (s == ConState.read) { ReadClick(); } else if (s == ConState.write) { WriteClick(); } } else { Common.Common.massage = "Connect Time Out"; SetEnable(true); MsgBox.Show(Common.Common.massage); } } else { SetEnable(true); MsgBox.Show(Common.Common.massage); } } else { SetEnable(true); } }
/// <summary> /// 连接超时 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void timerSend_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { PortCommunication.timerSend.Enabled = false; // PortCommunication.timerSend.Interval = 0; //if (lg.IsHandleCreated) //{ // lg.Invoke(new Action(() => // { // lg.Close(); // })); // } if (conn.IsAlive) { conn.Abort(); } PortCommunication.closePort(); barEditItem3.Value = 0; if (dataerrer == true) { if (!issessce) { if (conCount <= 1) { conCount++; Thread.Sleep(200); if (s == ConState.read) { ReadClick(); } else if (s == ConState.write) { WriteClick(); } } else { Common.Common.massage = "Connect Time Out"; foreach (Control item in this.Controls) { item.Enabled = true; } MessageBox.Show(Common.Common.massage); } } else { foreach (Control item in this.Controls) { item.Enabled = true; } MessageBox.Show(Common.Common.massage); } } else { foreach (Control item in this.Controls) { item.Enabled = true; } } }