vslavik/winsparkle — pull request #10 by orng (2013-09-25 17:44:36+00:00)
Title: Shutdown on update/installer launch

Hey. Here is an attempt to implement the functionality to shut down the host application upon launching the installer.
I'd love it if you could find the time to go over this and tell me what you think. I kind of feel like I have made a mess of things in UI.cpp. C++ is not my strongest language so just tell me your opinions and I'll try to accommodate them.

The way this new feature works is that now we have two new API methods exposed:
win_sparkle_set_shutdown_poll_callback and
win_sparkle_set_shutdown_request_callback

Both of them take function pointers as the only argument and are pretty self-explainatory:
shutdown_poll_callback is for asking the host if it is ready to shut down and returns a boolean, true if ready, false otherwise.
shutdown_request_callback is for telling the host to actually shut down once it has told us that it is ready

By setting these callbacks WinSparkle will wait for the host to be ready to terminate before running the installer upon an update. When it has gotten the go ahead from the host it will launch the installer and immediately ask the host to terminate.
This is not perfect and, as you have already talked about, can break if the termination takes long.
But we currently rely on the installer to make sure that the application isn't running so we can continue to do that for those cases. For the cases when this actually works however, it will provide a better user experience.