0

我正在升级桌面应用程序以在支持 BLE 的 Windows 10 上运行。我修改了应用程序以定位到相应的 Windows 版本,如本问题(如何在控制台中引用 Windows 8 运行时)中所述。现在尝试像本示例中那样一步一步地进行操作(Using BLE GATT services with Windows 10)。首先,我需要运行 ble scan,如下所示:

var devices = deviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid(GattServiceUuids.HeartRate));
if (devices != null)
{
   foreach (DeviceInformation device in devices)
   {
       // add device into your UI here
   }
}

但是在编译时我得到与foreach循环相关的错误,这是错误:

错误 CS1579 foreach 语句无法对“Windows.Foundation.IAsyncOperation”类型的变量进行操作,因为“Windows.Foundation.IAsyncOperation”不包含“GetEnumerator”的公共定义

4

0 回答 0