How to stop a long-running exe process (part of the package) and started by the app gracefully when the package is updated #4537
Unanswered
JosHuybrighs
asked this question in
Q&A
Replies: 1 comment 5 replies
-
My idea was to add a message only window, which handles I'm afraid that you'll need a visible window, otherwise it doesn't work. But I didn't test it enough. Hopefully someone at Microsoft could explain us, how Windows shuts down the processes when a MSIX package is being updated. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a WinUI/WinAppSDK desktop app in the Microsoft Store which, after being installed must be prepared to carry out various activities in the background and this both when the app is opened and closed. These activities are:
Except for the last service one can wonder why the app isn't using the BackgroundTask principles of WinAppSDK to handle this but as it has been pointed out in various topics about this (see #4014, #2322, #4115 ) at this moment only the timer triggered BackGroundTask really works in WindowsAppSDK.
Hence, my current solution unfortunately is to add a small "windows.startupTask" executable to the package that starts the first time the app is opened and then automatically each time the computer starts. It uses a
PeriodicTimer
to wait for the timeout,DeviceInformation.CreateWatcher
to handle USB device inserts, and aTCP server
implementation to listen for multicast messages. Of course it most of the time must do nothing. The 'main' part must wait in principle forever and does this as follows:This works without any problems and also has little or no impact on resources in the system.
The only issue is that when the app is updated Windows can't gracefully shutdown the 'background' process resulting in errors in the Windows Event Log.
An "AppIsToBeUpdated" trigger would be beneficial here but it unfortunately doesn't exists. Are there other possibilities to make this better? Is there some kind of message that I can react upon to kill the process myself? I tried to change the exe to work with a message pump but the windows triggered 'kill' request doesn't come in.
Beta Was this translation helpful? Give feedback.
All reactions