0

I try to receive user's PushNotification Channel URI (Windows 10 platform) and for some users application generate exception This operation returned because the timeout.

To handle errors in a task chain I should add a task-based continuation at the end of the chain and handle all errors there (as explained here https://learn.microsoft.com/en-us/windows/uwp/threading-async/asynchronous-programming-in-cpp-universal-windows-platform-apps#handling-errors-in-a-task-chain).

So I did that. But after I call t.get(); system generate Platform::COMException^ exception by it not catch in try-catch block. Why?

There is the code:

{
    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!");
        }
    });
}

There is the full exception message:

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

And Visual Studio throws me to the file c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\exception to block:

[[noreturn]] void _RethrowException() const
    {
    __ExceptionPtrRethrow(this); // <<<< here everything stoped!
    }

UPDATED:

Enviroment:

  • Visual Studio 2017 (15.7.3)
  • Project based on cocos2d-x (3.16)
  • Project Targe Platform Version = 10.0.1493.0
  • Project Platform Toolset = Visual Studio 2015 (v140)

You can clone cocos2dx project and in MainScene paste code I showed before in onEnter method (or anywhere).

I got a situation when I had crash 100% for me

  1. Uninstall app if it was built before;
  2. Disconnect from the internet;
  3. Build app & launch;
  4. The app will try to detect Channel URI & will crash (but with crash message = WinRT information: The network is not present or not started).

I understand that throwing that exception is normal. But I still cannot understand why when I call t.get() it not catch exception Platform::COMException^

  • Tested on my side cannot reproduce your issue.Please provide more information: your uwp app target version, your testing environment. A [mcve] will be preferred. – Sunteen Wu Jun 26 '18 at 03:27
  • @SunteenWu-MSFT I updated question & added enviroment info & situation when I had 100% crash – Andrei Bakulin Jun 27 '18 at 15:04
  • I can run into the catch please see [this picture](https://i.stack.imgur.com/J0lNO.png). The exception will throw when debug, but the app will not crash if you catch it. I don't have a project based on coco2d-x, could you lease try to create a blank app with above code snippet on your side and test again? We can try to narrow the issue firstly. – Sunteen Wu Jul 03 '18 at 06:10

0 Answers0