I tried using IPackageDebugSettings.GetPackageExecutionState, but it returns PES_RUNNING despite no app windows being open, and in the Task Manager "Status" column the exe showing "Suspended".
My final goal is to launch the app in suspended state, but only if it was not already running (scenario requires me to raise an error in that case). If it was running already in the background, I need to gracefully shut it down. The app in question is a third-party app.
I had the same problem during testing, but when I used
GetPackageExecutionStatedirectly I was able to read the correct state of the UWP application.You can launch the UWP application from Start Menu and do not use EnableDebugging method. You can refer to following code.