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

Jos Huybrighs 336 Reputation points
2019-12-14T18:42:27.363+00:00

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?

Universal Windows Platform (UWP)
{count} votes

1 answer

Sort by: Most helpful
  1. Jos Huybrighs 336 Reputation points
    2019-12-19T10:30:56.723+00:00

    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.