0

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?

CBHacking
  • 1,984
  • 16
  • 20
  • Have you considered making the desktop app a singleton, and then reuse the running instance whenever you start a new one? https://stackoverflow.com/questions/6486195/ensuring-only-one-application-instance – Stefan Wick MSFT Sep 12 '17 at 00:45
  • Making it a singleton would solve the concerns but require making changes to the desktop app. I'd prefer an approach that didn't require it but this is probably easier. – CBHacking Sep 12 '17 at 06:34
  • @CBHacking have you solved this. I have same problem. – neo Mar 26 '18 at 06:42
  • @neo I found some hacky work-arounds, like having the desktop app create a file (where the sandboxed app could see it) that is opened as the kind of temp file that is deleted when the handle is closed. The sandboxed app can then check for the file's existence. You also *can* get a named object, such as an event, to share between a desktop and sandbox app, though it requires violating the documented spec (the spec says you can't use path separators in an object name, but you need to if you're doing this). In general, though, I think it's still something MS needs to improve. – CBHacking Mar 26 '18 at 07:04

0 Answers0