I am using C# to develop a UWP app for Windows 10 running only on desktop computers, targeting platform version 10.0.14393.0. Due to business requirements, the app lifecycle must behave like a traditional Win32 application.
Therefore, I followed the recommendation from this article to request an ExtendedExecutionSession
with ExtendedExecutionReason.Unspecified
. I also configured Windows to never sleep and never hibernate.
Still, on rare occasions, Windows will revoke the extended execution session with reason SystemPolicy
and then proceed to suspend the UWP app.
Two questions:
Thanks!
Go to Start > Settings > Privacy > scroll down to Background apps > select the app in question & toggle "Off" to turn it off.
The UWP process is suspended for a variety of reasons. When the user minimizes the application. When the system enters a low-power state.
Launch Task Manager via Ctrl+Shift+Esc shortcut keys. Then select the suspended program and click End Task. This should stop the suspended process in Windows 11.
Once it is in suspend state CPU cycles are not used. You can resume the process by right click on the same process and then clicking on Resume Process.
Yes: In your manifest, go to the VisualElements element and add the attribute AppListEntry="none" . This removes the app from the Start menu, as well as from Search.
Microsoft continues to baby-step around the obvious, but it has officially deprecated the Universal Windows Platform (UWP) as it pushes the desktop-focused Windows App SDK (formerly called Project Reunion) and WinUI 3 as the future of Windows application development.
ExtendedExecutionSession
with ExtendedExecutionReason.Unspecified
is a subject to multiple restrictions regarding resource consumption. Since your test device doesn't have a battery, then the most likely reason for your app getting suspended is its high memory use. You can try to optimize the app in terms of memory consumption and make use of Memory Management APIs as documentation suggests, but still this doesn't guarantee that your app will never get suspended.
If your app is aimed at business sector then you might consider using more powerful ExtendedExecutionForegroundSession
instead of ExtendedExecutionSession
. This would probably be the perfect solution for your problem. But it's a restricted capability, which means an app that utilizes it is not allowed to Windows Store - only to Windows Store for Business. You'd also need to manually declare the extendedExecutionUnconstrained
capability in the manifest (see the Special and restricted capabilities section of documentation) to take advantage of the API.
Alternatively you can use hacks that prevent app from getting suspended for long periods of time:
Use of App services for communicating with Win32 apps as pnp0a03 suggested.
Use Background Media Playback for playing silent audio sample in the background infinitely in a loop (even if the user stops it manually or another app pauses it to play its own background audio, your app can trace it and automatically restart the playback).
I was trying to solve this for days and days but then found this link. Very good explanation and solution to this and most importantly.. easy to understand. You need to put the code in the app.xaml.cs and also edit the package manifest file. You will also need the following directives in the app.xaml.cs
using Windows.ApplicationModel.ExtendedExecution.Foreground; using System.Threading.Tasks;
non-suspending-uwp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With