question

Kenneth-1983 avatar image
0 Votes"
Kenneth-1983 asked Viorel-1 edited

C++/WinRT BackgroundTaskRegistration::AllTasks static method stuck and not returning

I am following the notification listener docs, and one of the steps to register a background notification listener is to first check whether an existing one is already registered, by calling BackgroundTaskRegistration::AllTasks() to get all existing tasks, then enumerating over the map to see if one can be found. However, it seems like the method is not responding at all, as it is not returning anything and the code that follows isn't executed.

 std::cout << "before" << std::endl;
 auto all_tasks = BackgroundTaskRegistration::AllTasks();
 std::cout << "after" << std::endl;

"before" is printed to the console but "after" is not.

For context, I am calling the method in a win32 context (Flutter desktop). Previous WinRT API calls like UserNotificationListener::Current() work just fine.

Any help is appreciated!

Envrionment:
- Windows 11 22000.65
- Visual Studio 2019
- Flutter 2.2 with windows desktop support enabled
- CMake 3.15 project (generated by Flutter)








not-supported
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Currently, Microsoft Q&A supports the products listed over here: supported topics (more to be added later on).
Questions that happens in a third-party project are not supported in Microsoft now. You could try to reproduce this issue in a C++/Winrt UWP project. If this issue still exists, please post your question here.

0 Votes 0 ·

Did you consider experimenting with some sample projects, for example: https://github.com/microsoft/Windows-universal-samples/tree/main/Samples/BackgroundTask/cs/BackgroundTask? Maybe, for some reasons, the problem is not reproduced in C# UWP projects. There are C++ samples too.

0 Votes 0 ·

0 Answers