private async void OnSearchCompleted(Task <List <BluetoothDeviceInfo> > obj) { List <BluetoothDeviceInfo> results = await obj; if (results == null) { MessageBox.Show("Failed to discover Bluetooth devices, \nIs Bluetooth turned on?", "Can't find Devices", MessageBoxButton.OK, MessageBoxImage.Error); return; } App.Current.Dispatcher.Invoke((Action) delegate { list.Clear(); }); foreach (var Result in results) { DeviceDetails dd = new DeviceDetails { Name = Result.DeviceName, Adress = Result.DeviceAddress.ToString() }; App.Current.Dispatcher.Invoke((Action) delegate { list.Add(dd); }); } //bluetoothDeviceInfo = results; }
private void LocalComponent_DiscoverDevicesProgress(object sender, DiscoverDevicesEventArgs e) { foreach (var dev in e.Devices) { DeviceDetails dd = new DeviceDetails { Name = dev.DeviceName, Adress = dev.DeviceAddress.ToString() }; App.Current.Dispatcher.Invoke((Action) delegate { observableCollection.Add(dd); latestsearch.Add(dev); }); } }