【发布时间】:2019-12-24 14:47:00
【问题描述】:
现在我试图在读取和处理文件时显示进度条对话框,但我的代码在关闭对话框时抛出“读取访问冲突”。
确切的错误信息是,
**__pUnknown** was 0xFFFFFFFFFFFFFFFF.
下面是我的代码。
void LoadFile(StorageFile^ file) {
ContentDialog^ loaderDialog = ref new ContentDialog();
loaderDialog->Title = L"Loading...";
loaderDialog->Content = ref new ProgressBar();
loaderDialog->ShowAsync();
Concurrency::create_task(FileIO::ReadTextAsync(file))
.then([&](Platform::String^ fileText) {
// File processing parts are omitted.
// ...
loaderDialog->Hide(); // Read access violation!
}
);
}
为什么这会变成错误?
【问题讨论】:
-
不是 C++/CX 方面的专家,但我会尝试通过值 [=] 而不是通过引用 [&] 来捕获。
-
@CuriouslyRecurringThoughts 我认为你是专家!谢谢,问题解决了!
标签: windows win-universal-app c++-cx