如何在c ++ / WRL上执行与C#异步等待相同的操作

时间:2014-08-12 12:35:42

标签: c# c++ asynchronous wrl

我正在尝试c ++ / WRL,但我没有做基础知识,主要是调用异步函数并获取结果,例如如何获取由以下代码返回的IStorageFile:

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);

如何执行 filePathStorage IAsyncOperation对象?我怎么能用c ++ / WRL做到这一点?

0 个答案:

没有答案