Due to lack of full support for CommandLineActivatedEventArgs - #6431 - I've been augmenting app instance redirection with my own version for that case. One thing I've noticed in examining the code is that it's possible for an instance to hang indefinitely if the instance it's redirecting to is in the process of shutting down. It would be quite easy to mitigate against this.
In this file https://github.com/microsoft/WindowsAppSDK/blob/main/dev/AppLifecycle/AppInstance.cpp, all you would need to do is signal the cleanupEvent (if it exists) in the onInstanceTerminated handler, and also check that the process is still open just after creating the cleanupEvent (else fail). In an ideal world you might also communicate the error to the waiting process (I guess you might need a second event to signal the error or use a memory mapped file), but in my opinion it's probably better for the waiting process to carry on as normal (usually just exit) rather than hang indefinitely in this case.
Due to lack of full support for CommandLineActivatedEventArgs - #6431 - I've been augmenting app instance redirection with my own version for that case. One thing I've noticed in examining the code is that it's possible for an instance to hang indefinitely if the instance it's redirecting to is in the process of shutting down. It would be quite easy to mitigate against this.
In this file https://github.com/microsoft/WindowsAppSDK/blob/main/dev/AppLifecycle/AppInstance.cpp, all you would need to do is signal the
cleanupEvent(if it exists) in theonInstanceTerminatedhandler, and also check that the process is still open just after creating thecleanupEvent(else fail). In an ideal world you might also communicate the error to the waiting process (I guess you might need a second event to signal the error or use a memory mapped file), but in my opinion it's probably better for the waiting process to carry on as normal (usually just exit) rather than hang indefinitely in this case.