COMException^ 在 FilePicker PickSingleFileAsync() 调用上

COMException^ on FilePicker PickSingleFileAsync() call

我正在尝试制作游戏(通用 DX11 应用程序),有时我需要访问图像库以允许用户 select 头像。但是由于某种原因,在选取器上调用 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

好的,我只是决定调用 dipatcher 的 RunAsync 来执行这段代码。但我仍然不知道为什么我不能在非UI线程中打开选择器。