public override async Task OnNavigatedFromAsync(IDictionary <string, object> suspensionState, bool suspending) { if (suspending) { suspensionState[nameof(Value)] = Value; } bluetoothListener?.Dispose(); bluetoothListener = null; await Task.CompletedTask; }
public void StopListening() { if (_isConnected) { throw new BluetoothServiceException("Service cannot stop listing when it is a sender."); } // If the service isn't listening just return if (!_isListening) { return; } _cancelToken.Cancel(); _listener.Dispose(); _listener = null; if (_client != null) { _client.Dispose(); _client = null; } _isListening = false; }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { Stop(); _listener.Dispose(); }