How to execute the same as the C# async await on c++/WRL

192 Views Asked by At

i'm trying the c++/WRL but i'm failing to do the basics, mainly call a async function and obtain the result, for example how to get the IStorageFile returned by the following code:

HString path;
path.Set(L"C:\\somepath\\somefile.txt");

// Get the Activation Factory
ComPtr<IActivationFactory> pStorageFileActivationFactory;
hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Storage_StorageFile).Get(), &pStorageFileActivationFactory);
if (FAILED(hr))
{
    return PrintError(__LINE__, hr);
}
ComPtr<IStorageFileStatics> pStorageFileStatics;
hr = pStorageFileActivationFactory.As(&pStorageFileStatics);

__FIAsyncOperation_1_Windows__CStorage__CStorageFile* filePathStorage;
hr = pStorageFileStatics->GetFileFromPathAsync(path.Get(), &filePathStorage);

How can i execute the filePathStorage IAsyncOperation object? how can i do this in c++/WRL?

0

There are 0 best solutions below