0

I am working on upgrading desktop app to run on windows 10 with BLE support. I modified the app to target to corresponding windows version as described in this question (How can I reference the Windows 8 Runtime in console). Now trying to do step by step as in this example (Using BLE GATT services with Windows 10). First of all I need run ble scan as follows:

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

But on compilation i get error related to foreach loop, here is the error:

Error CS1579 foreach statement cannot operate on variables of type 'Windows.Foundation.IAsyncOperation' because 'Windows.Foundation.IAsyncOperation' does not contain a public definition for 'GetEnumerator'

Community
  • 1
  • 1
  • 1
    You must **await** methods whose name ends in "Async". – Hans Passant Apr 25 '16 at 09:07
  • @Hans Passsant thanks, this is helpful. I added **async** and **await** keywords, also used suggestions from [this post](http://stackoverflow.com/questions/10428446/storagefile-async-usage-in-a-non-metro-application/19731831#19731831) and seems error disappeared – Vladimir Tsykunov Apr 25 '16 at 09:48

0 Answers0