UWP detect if Desktop Bridge app is running

411 Views Asked by At

I have a UWP that also contains a desktop bridge component. The UWP contains the interactive code, including handling session management (login and logout). The desktop app runs in the background - it displays no UI most of the time - but must always be running when the app's user is signed in (the UWP and desktop components share auth). If the desktop app is not running when the UWP starts, but the app is signed in, the UWP needs to start the desktop app. Similarly, whenever the UWP signs in a user, it needs to start the desktop component (if it isn't already running). Signing out a user doesn't strictly require exiting the desktop app, though it wouldn't hurt. Critically, the desktop component must not (automatically) exit when the UWP exits, so there's no guarantee on launch of the UWP whether the desktop app was launched by a previous instance (and is still running) or not.

The problem is, I can't find a way for a UWP to detect whether its desktop bridge component is already running, or to kill an already-running instance. The methods in FullTrustProcessLauncher do not return a Process object or any other way to monitor the desktop app.

How can a UWP detect if its desktop bridge component is running? If it is running, can the UWP stop the desktop bridge app?

0

There are 0 best solutions below