Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question error CS1929: 'IAsyncOperation<>' does not contain a definition for 'GetAwaiter'

Discussion in 'Windows' started by glingicom, Aug 4, 2023.

  1. glingicom

    glingicom

    Joined:
    Oct 19, 2020
    Posts:
    2
    Hi.

    I tried to apply Microsoft UWP BluetoothLE project to Unity.
    Windows-universal-samples/Samples/BluetoothLE at main · microsoft/Windows-universal-samples · GitHub

    When I worte codes as below, I got error.

    Code (CSharp):
    1.  
    2.     // BT_Code: BluetoothLEDevice.FromIdAsync must be called from a UI thread because it may prompt for consent.
    3.         Windows.Devices.Bluetooth.BluetoothLEDevice  bluetoothLeDevice = await  Windows.Devices.Bluetooth.BluetoothLEDevice.FromIdAsync(bleDeviceId);
    4.  
    5.     // this is the definition of BluetoothLEDevice.FromIdAsync()
    6.         public static extern IAsyncOperation<BluetoothLEDevice> FromIdAsync([In] string deviceId);
    7.  
    Code (CSharp):
    1.  
    2. Assets\Scripts\my_script.cs: error CS1929: 'IAsyncOperation<BluetoothLEDevice>' does not contain a definition for 'GetAwaiter' and the best extension method overload 'AwaitExtensions.GetAwaiter(Process)' requires a receiver of type 'Process'
    3.  

    In player settings menu, the Api Compatibility Level wisas set to ".NET 4.x".

    What is the problem and solution?

    Thanks
     
    Last edited: Aug 4, 2023
  2. glingicom

    glingicom

    Joined:
    Oct 19, 2020
    Posts:
    2
    nikhilgowda likes this.
  3. nikhilgowda

    nikhilgowda

    Joined:
    Dec 14, 2022
    Posts:
    1
    I was thinking of using UWP but isn't it being deprecated (or sunsetted) soon basically?
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,628
    That depends on how you look at it. It's unlikely to ever be removed from Windows, so your application will keep working. We also still support it as of Unity 2023.2 and it will be supported in Unity 2023 LTS, which will receive updates to at least 2026.