question

JosHuybrighs-1920 avatar image
0 Votes"
JosHuybrighs-1920 asked RoyLi-MSFT commented

UWP TimerTrigger'd background task doesn't run while in lockscreen

I have a UWP app which registers an in-process background task that must run every 15 minutes.
The background task runs effectively every 15..20 minutes after the computer has been started up and the computer remains active. As soon as the computer goes in lock screen the task doesn't run anymore. When the computer is later unlocked, the task runs again. The computer is permanently powered (doesn't run on battery) and I have configured the device not to go in sleep state. The screen is configured to go off after 10 minutes of inactivity.
To check whether the task runs I have put a log statement as first instruction in the Run() method. The log text goes to a file in LocalState.

From the documentation I learned that since Windows 10 UWP apps should be allowed to run when the computer is locked.

Is this true or doesn't this apply to time triggered background tasks?

windows-uwp
· 4
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.

I could reproduce this. I made a sample for this. I will write the time into a local file when the background task is triggered. There is no text is written into the file when the device is in lock screen mode. I will consult this issue with the team.

0 Votes 0 ·

The team told me that this behavior is by design. May I know why you need your app to run in lock screen mode?

Using extended execution, it is possible for the app to run from the lock screen but there is no guarantee that the app with run.


0 Votes 0 ·

My app is a folder sync/backup app with a win32 full trust process that is triggered by the UWP background task when a backup job must be executed. It tries to behave like the task schedular in windows but then as a UWP desktop bridge app (where access to the schedular is not possible from within UWP).
It is the only option for scheduled backup when going the UWP way.

It is actually not so important because the trigger will anyhow come shortly after the computer becomes active again and so backup/sync, which should have been executed while in lock state, eventually will get executed.

If I would do it again I would probably start from a win32 WPF program and use XAML Island for the UI. But that is now. My app is already more than 1 year old and at that point in time publishing a WPF app on Microsoft Store was not so much supported. Don't know actually today whether I will be able to publish a WPF app as a software developer not associated with any company.

0 Votes 0 ·

You could publish your app just as an individual developer. Just select individual for developer account type when you register your developer account. And another thing is that you could only upload desktop bridge apps or native UWP apps to the Store, not native WPF apps.


0 Votes 0 ·

1 Answer

JosHuybrighs-1920 avatar image
0 Votes"
JosHuybrighs-1920 answered RoyLi-MSFT commented

My observation now after a couple of years of UWP development for apps that have to be published on Microsoft Store is:

  • Use pure UWP when it is OK to run your app in a sandbox and you don't need full access to the file system and/or want to run long lasting background tasks without a UI (i.e. time triggered tasks, network listening tasks, etc.).

  • Use desktop bridge with a WPF process as entry point and XAML island with UWP controls for the UI when full access to the file system is needed and when you want to run any type of process/task in the background.

My conclusion today then is: Any serious project requires desktop bridge with WPF. When you go the UWP way somewhere along the road you will probably hit a wall.




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

Yes, UWP apps are different from WPF apps. UWP apps have more limitations for security reasons. You could choose one of them depends on what kind of function you want to achieve.

0 Votes 0 ·