getBasicPropertiesAsync method

Future<BasicProperties?> getBasicPropertiesAsync()

Implementation

Future<BasicProperties?> getBasicPropertiesAsync() {
  final retValuePtr = calloc<COMObject>();
  final completer = Completer<BasicProperties?>();

  final hr = ptr.ref.vtable
          .elementAt(10)
          .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<BasicProperties?>.fromRawPointer(
      retValuePtr,
      creator: BasicProperties.fromRawPointer);
  completeAsyncOperation(
      asyncOperation, completer, asyncOperation.getResults);

  return completer.future;
}