1

I have example code and code I am currently writing. Both set have the exact same references. The example code HeartRateLE which I got from GitHub compiles and runs fine. The code I am working on does not compile because of

this code

IAsyncOperation<BluetoothLEDevice>  myTask =
              BluetoothLEDevice.FromIdAsync(deviceId);
var device = myTask.GetAwaiter().GetResults();

as GetAwaiter does not reference using System; Actually using System; at the top of the class is grayed out showing its not in use.

Both have the Reference of System and both have the same path of C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.8\System.dll

Both also have the Reference of Windows.WinMD with the same path of C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Facade\Windows.WinMD

Here is the error for GetAwaiter

Error CS4036 'IAsyncOperation<BluetoothLEDevice>' does not contain a definition for 'GetAwaiter' and no extension method 'GetAwaiter' accepting a first argument of type 'IAsyncOperation<BluetoothLEDevice>' could be found (are you missing a using directive for 'System'?)

I would like to know how to fix it so that GetAwaiter references System.

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
DanDownen
  • 13
  • 2

2 Answers2

0

using System.WindowsRuntimeSystemExtensions;

For more info

https://learn.microsoft.com/en-us/dotnet/api/system.windowsruntimesystemextensions?view=dotnet-plat-ext-3.1

0

Add below using, this is from the System.Runtime.WindowsRuntime assembly and holds a class with the GetAwaiter extensions.

using System.WindowsRuntimeSystemExtensions;

Rajanikant Hawaldar
  • 314
  • 1
  • 5
  • 12