public void Close() { // Cancel the connection worker if active connectionWorker.CancelAsync(); // De-register the events _selectedDevice.Inserted -= Device_Inserted; _selectedDevice.Removed -= Device_Removed; // Nullify the selected device _selectedDevice.CloseDevice(); _selectedDevice = null; }