I'm trying to get a BluetoothDevice
from its address.
When I try this:
// type of e is BluetoothLEAdvertisementReceivedEventArgs
BluetoothDevice device = BluetoothDevice.FromBluetoothAddressAsync(e.BluetoothAddress);
I get this error:
Cannot implicitly convert type "Windows.Foundation.IAsyncOperation<Windows.Devices.Bluetooth.BluetoothDevice>" to "Windows.Devices.Bluetooth.BluetoothDevice"
In a similar post someone recommended to use a async method with await. So I tried this:
private async void NewDeviceDetected(BluetoothLEAdvertisementReceivedEventArgs e)
{
if (InvokeRequired)
{
this.Invoke(new Action(() => NewDeviceDetected(e)));
return;
}
//Get Device
BluetoothDevice device = await BluetoothDevice.FromBluetoothAddressAsync(e.BluetoothAddress);
}
but now I'm getting this error:
'IAsyncOperation<BluetoothDevice>' does not contain a definition for 'GetAwaiter' and no extension method 'GetAwaiter' accepting a first argument of type 'IAsyncOperation<BluetoothDevice>' could be found (are you missing a using directive for 'System'?)
I am using System;