getConnectedProfileAsync method

Future<ConnectionProfile?> getConnectedProfileAsync()

Implementation

Future<ConnectionProfile?> getConnectedProfileAsync() {
  final retValuePtr = calloc<COMObject>();
  final completer = Completer<ConnectionProfile?>();

  final hr = ptr.ref.vtable
          .elementAt(11)
          .cast<
              Pointer<
                  NativeFunction<
                      HRESULT Function(Pointer, Pointer<COMObject>)>>>()
          .value
          .asFunction<int Function(Pointer, Pointer<COMObject>)>()(
      ptr.ref.lpVtbl, retValuePtr);

  if (FAILED(hr)) {
    free(retValuePtr);
    throw WindowsException(hr);
  }

  final asyncOperation = IAsyncOperation<ConnectionProfile?>.fromRawPointer(
      retValuePtr,
      creator: ConnectionProfile.fromRawPointer);
  completeAsyncOperation(
      asyncOperation, completer, asyncOperation.getResults);

  return completer.future;
}