public async void Dispose()
        {
            try
            {
                await _backend.DisconnectAsync();
            }
            catch (Exception ex)
            {
                Log.Warning("BluetoothImpl.Dispose: Error while disconnecting: " + ex);
            }

            MessageReceived -= SPPMessageHandler.Instance.MessageReceiver;

            _cancelSource.Cancel();

            await Task.Delay(50);

            try
            {
                _loop?.Dispose();
                _cancelSource.Dispose();
            }
            catch (Exception ex)
            {
                Log.Error("BluetoothImpl.Dispose: Error while disposing children: " + ex);
            }
        }
Exemple #2
0
 public async Task DisconnectAsync()
 {
     try
     {
         await _backend.DisconnectAsync();
     }
     catch (BluetoothException ex)
     {
         OnBluetoothError(ex);
     }
 }