public override void ReleaseSession() { ReleaseOperations(); if (m_serialPort != null) { m_serialPort.Close(); m_serialPort.Dispose(); m_serialPort = null; } }
/// <summary> /// Closes the serial port and stops the serial communication thread. /// </summary> public void End() { if (this.commThread != null) { commThread.Abort(); if (serialDevice != null && serialDevice.IsOpen) { serialDevice.Close(); } commThread = null; } /*if (serialDevice != null && serialDevice.IsOpen) * { * if (this.commThread != null) * { * commThread.Abort(); * if (commThread.ThreadState == ThreadState.Aborted) * { * serialDevice.Close(); * } * commThread = null; * } * * } */ }
/// <summary> /// Disposing a serial port in case of updating desired properties /// </summary> private static void DisposeSerialPort(ISerialDevice serialPort) { if (serialPort != null) { serialPort.Close(); Log.Debug($"Serial port disposed"); } Log.Debug("No serial port to dispose"); }