public async void Disconnect() { disconnecting = true; connected = false; if (_buttonService != null) { using (_buttonService) { _buttonService.Error -= OnServiceError; _buttonService.ConnectionChanged -= OnConnectionChanged; _buttonService = null; } } if (_accelService != null) { using (_accelService) { try { _accelService.Error -= OnServiceError; _accelService.ConnectionChanged -= OnConnectionChanged; await _accelService.StopReading(); } catch { } _accelService = null; } } }
public async void Disconnect() { disconnecting = true; connected = false; if (_tempService != null) { using (_tempService) { try { _tempService.Error -= OnServiceError; _tempService.ConnectionChanged -= OnConnectionChanged; await _tempService.StopReading(); } catch { } _tempService = null; } } if (_buttonService != null) { using (_buttonService) { _buttonService.Error -= OnServiceError; _buttonService.ConnectionChanged -= OnConnectionChanged; _buttonService = null; } } if (_accelService != null) { using (_accelService) { try { _accelService.Error -= OnServiceError; _accelService.ConnectionChanged -= OnConnectionChanged; await _accelService.StopReading(); } catch { } _accelService = null; } } if (_gyroService != null) { using (_gyroService) { try { _gyroService.Error -= OnServiceError; _gyroService.ConnectionChanged -= OnConnectionChanged; await _gyroService.StopReading(); } catch { } _gyroService = null; } } if (_magService != null) { using (_magService) { try { _magService.Error -= OnServiceError; _magService.ConnectionChanged -= OnConnectionChanged; await _magService.StopReading(); } catch { } _magService = null; } } if (_humidityService != null) { using (_humidityService) { try { _humidityService.Error -= OnServiceError; _humidityService.ConnectionChanged -= OnConnectionChanged; await _humidityService.StopReading(); } catch { } _humidityService = null; } } if (_barometerService != null) { using (_barometerService) { try { _barometerService.Error -= OnServiceError; _barometerService.ConnectionChanged -= OnConnectionChanged; await _barometerService.StopReading(); } catch { } _barometerService = null; } } if (_motionService != null) { using (_motionService) { try { _motionService.Error -= OnServiceError; _motionService.ConnectionChanged -= OnConnectionChanged; await _motionService.StopReading(); } catch { } _motionService = null; } } if (_lightService != null) { using (_lightService) { try { _lightService.Error -= OnServiceError; _lightService.ConnectionChanged -= OnConnectionChanged; await _lightService.StopReading(); } catch { } _lightService = null; } } }