public int CloseSession() { if (m_connectType == 1) { try { mbSession.Terminate(); mbSession.Dispose(); } catch (Exception) { return(-1); } bsessionopen = false; m_ConnectManager = null; } else if (m_connectType == 0) { bsessionopen = false; try { m_SerialPort.Close(); } catch (Exception) { return(-1); } m_SerialPort = null; } return(0); }