Beispiel #1
0
 public override void Disconnect()
 {
     try
     {
         ClearCmd();
         Cmd.Clear();
         ReadTimer.Change(-1, -1);
         WriteTimer.Change(-1, -1);
         WaitUntilThreadOver();
         serialport.Close();
         CreateEvent(EventReason.Disconnected, null);
     }
     catch (Exception ex)
     {
         CreateEvent(EventReason.Disconnected, ex.Message);
     }
     finally
     {
         PACK.FlushReadBuffer();
         PACK.FlushWriteBuffer();
         CMD.ClearTask();
         serialport = null;
     }
 }