private void _adapter_ScanTimeoutElapsed(object sender, EventArgs e) { _cancellationTokenSource?.Dispose(); _cancellationTokenSource = null; DeviceScanTimeout?.Invoke(this, null); }
async void SearchBand() { try { var bandClientManager = BandClientManager.Instance; // query the service for paired devices var pairedBands = await bandClientManager.GetPairedBandsAsync(); // connect to the first device var bandInfo = pairedBands.FirstOrDefault(); var bandClient = await bandClientManager.ConnectAsync(bandInfo); DeviceScanUpdate?.Invoke(this, bandInfo.Name); await Task.Delay(3000); DeviceScanTimeout?.Invoke(this, null); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); await Task.Delay(3000); DeviceScanTimeout?.Invoke(this, null); } }