question

AndrewGagua-9592 avatar image
0 Votes"
AndrewGagua-9592 asked ·

UWP. UI tasks does not running when application is hidden.

 auto workItemHandler = ref new WorkItemHandler( [this]( IAsyncAction^ action )
             {
                 while ( action->Status == AsyncStatus::Started )
                 {
                     WaitForSingleObjectEx( GetCurrentThread(), 1, FALSE );
            
                     if ( !processDispached )
                     {
                         processDispached = true;
            
                         swapChainPanel->Dispatcher->RunIdleAsync( ref new IdleDispatchedHandler( [=]( Object^ object )
                         {
                             ToDoSomething();
                             processDispached = false;
                         } ) );
                     }
                 }
             } );

Hello.

I have an application with xaml. I'm creating a 'WorkItemHandler' for main application loop, but some logic processed in the ui thread.

But method 'RunIdleAsync' doesn't start when the application is hidden.

How can i fix this? And can i do this?

windows-uwpwindows-uwp-xaml
10 |1000 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.

1 Answer

NicoZhu-MSFT avatar image
1 Vote"
NicoZhu-MSFT answered ·

UWP. UI tasks does not running when application is hidden.

UWP has the specific life cycle , if the app is hidden, it will Suspended(The user either minimized or switched away from your app and didn't return to it within a few seconds.) the ui thread will stop running.

alt text

if you want to process some data, you could use background tasks. And you could also use extended execution.

there are cases where an app may need to keep running, rather than be suspended, when the user navigates away from the app, or while it is minimized. For example, a step counting app needs to keep running and tracking steps even when the user navigates away to use other apps.

For more please refer this document.


· 1 ·
10 |1000 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.

Hello,
I'll try.

Thanks!

0 Votes 0 ·