spspli
spspli

Reputation: 3328

How to run a long running task when my uwp application is suspended?

I have an UWP application, which executes some long running task for up to 1 or 2 hours. When I minimize my UWP application, the status of my application turns to Suspended and my long running task is suspended too. I wonder whether I could keep my long running task doing its job while my UWP app is suspended. I want this work for desktop, tablet and laptop.

Seeing from this post, using ExtendedExecutionSession can only run a task less than 10 minutes if no wall power for desktop; for tablet or laptop, it could run as long as screen is on, up to the battery.

I also looked into background task or background transfer - it seems background task not supporting work like mine; and background transfer only supports file transfer.

The only option I could see now is a win32 application, I could include it as part of my uwp application. And I could launch a process for the win32 application, pass info from uwp to this win32 by app service connection, then when my uwp application is suspended, my win32 application could go on working on the long running task. After my long running task is done, I can activate my uwp application to resume.

Is there any other option I could take a look here? Is there anything wrong to use the win32 process to run my long running task when my uwp is suspended? I have experimental code to package them in one appx, uwp can launch win32 process, and they can communicate to each other. Any input or concerns or suggestions are welcomed!

Upvotes: 1

Views: 797

Answers (1)

Allstar
Allstar

Reputation: 439

If you are writing your UWP app for personal use/sideloading, and NOT the app store.. this MSDN link answers your question.

From that link: "If you are developing an app that is not intended to be submitted into the Microsoft Store, then you can use the ExtendedExecutionForegroundSession with the extendedExecutionUnconstrained restricted capability so that your app can continue to run while minimized, regardless of the energy state of the device.  "

Upvotes: 0

Related Questions