/// <summary> /// Stop access to the device. /// </summary> public override void Stop() { DebugWriteLine("Stop()"); try { if (_readHandle == null) { throw new InvalidOperationException("Cannot stop, device is not active"); } _notifyWindow.DeviceArrival -= OnDeviceArrival; _notifyWindow.DeviceRemoval -= OnDeviceRemoval; WriteSync(StopPacket); StopReadThread(); CloseDevice(); } catch (Exception ex) { DebugWriteLine(ex.ToString()); throw; } finally { _notifyWindow.UnregisterDeviceArrival(); _notifyWindow.Dispose(); _notifyWindow = null; DebugClose(); } }