我正在尝试制作游戏(Universal DX11应用程序),在某些时候我需要访问图像库以允许用户选择头像。但由于某些原因,在选择器上调用PickSingleFileAsync会引发异常。
Windows::Storage::Pickers::FileOpenPicker^ openPicker = ref new Windows::Storage::Pickers::FileOpenPicker();
openPicker->SuggestedStartLocation = Windows::Storage::Pickers::PickerLocationId::PicturesLibrary;
openPicker->ViewMode = Windows::Storage::Pickers::PickerViewMode::Thumbnail;
// Filter to include a sample subset of file types.
auto filters = openPicker->FileTypeFilter;
filters->Clear();
filters->Append(".png");
openPicker->PickSingleFileAsync();// same exception with create_task(...);
看起来样本只有在我把它放入UI线程时才有效。如何从我自己的线程中使用选择器?
UPD:HRESULT:0x80004005
答案 0 :(得分:1)
好的,我刚决定调用dipatcher的RunAsync来执行此代码。但我仍然不知道为什么我无法在非UI线程中打开选择器。