Пример #1
0
 private void Disconnection(bool stopListen = true)
 {
     CheckDisposed();
     DeviceDisconnecting?.Invoke(this);
     Disconnect();
     client?.Close();
     client?.Dispose();
     if (stopListen)
     {
         StopListen();
     }
     DeviceDisconnected?.Invoke(this);
 }
Пример #2
0
        public void Disconnect()
        {
            if (ConnectedDevice == null)
            {
                return;
            }

            DeviceDisconnecting?.Invoke(this, EventArgs.Empty);

            ConnectedDevice.Dispose();
            ConnectedDevice = null;

            DeviceDisconnected?.Invoke(this, EventArgs.Empty);
        }