/// <summary> /// Tries to disconnect from a device. /// </summary> /// <returns>The to disconnect device.</returns> /// <param name="sensorDeviceViewModel">Sensor device view model.</param> private async Task TryToDisconnectDevice() { _userDialogs.ShowLoading($"Started <TryToDisconnectDevice> task."); try { // Check if the device is not connected if (!IsConnected) { _log.Debug($"{DeviceName} has already disconnected. Aborting disconnect attempt."); _userDialogs.ShowLoading($"Disconnecting {DeviceName}..."); return; } _userDialogs.ShowLoading($"Disconnecting {DeviceName}..."); await _bluetoothService.DisconnectDevice(SensorDevice); } catch (Exception ex) { _userDialogs.Alert(ex.Message, "Disconnect error"); } finally { Update(); _userDialogs.HideLoading(); RaisePropertyChanged("ConnectOrDisposeActionString"); RaisePropertyChanged("ImageSource"); _parentViewModel.RaisePropertyChanged(); } }