我尝试接收用户的PushNotification Channel URI(Windows 10平台),并为某些用户应用程序生成异常This operation returned because the timeout
。
要处理任务链中的错误,我应该在链的末尾添加一个基于任务的延续,并在那里处理所有错误(如此处https://docs.microsoft.com/en-us/windows/uwp/threading-async/asynchronous-programming-in-cpp-universal-windows-platform-apps#handling-errors-in-a-task-chain所述)。
所以我做到了。但是,在我调用t.get();
之后,系统会通过try-catch块无法捕获到Platform::COMException^
异常。为什么?
有代码:
{
create_task(PushNotificationChannelManager::CreatePushNotificationChannelForApplicationAsync())
.then([this](PushNotificationChannel^ pnChannel)
{
// ..
// DONE: pnChannel->Uri
// ..
}, task_continuation_context::get_current_winrt_context())
.then([](task<void> t)
{
try
{
t.get(); // <<<< After exec this line app crash!
}
catch (Platform::COMException^ e)
{
OutputDebugString(L"Exception catches!");
}
});
}
有完整的异常消息:
Exception thrown at 0x00007FFD9D74A388 in GameName.exe: Microsoft C++
exception: Platform::COMException ^ at memory location 0x000000249A9FEB60.
HRESULT:0x800705B4 This operation returned because the timeout period expired.
WinRT information: This operation returned because the timeout
然后Visual Studio将我扔到文件c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\exception
中进行阻止:
[[noreturn]] void _RethrowException() const
{
__ExceptionPtrRethrow(this); // <<<< here everything stoped!
}
已更新:
环境:
您可以克隆cocos2dx项目,并在之前在onEnter方法(或任何位置)中显示的MainScene粘贴代码中进行复制。
我遇到了当我100%撞车的情况
WinRT information: The network is not present or not started
)。我知道抛出该异常是正常的。但是我仍然不明白为什么当我调用t.get()
时没有捕获到异常Platform::COMException^