openTransactedWriteAsync method

Future<StorageStreamTransaction?> openTransactedWriteAsync()

Implementation

Future<StorageStreamTransaction?> openTransactedWriteAsync() {
  final operation = calloc<COMObject>();

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

  if (FAILED(hr)) {
    free(operation);
    throwWindowsException(hr);
  }

  final asyncOperation = IAsyncOperation<StorageStreamTransaction?>.fromPtr(
      operation,
      creator: StorageStreamTransaction.fromPtr);
  return asyncOperation.toFuture(asyncOperation.getResults);
}