blikblum/luipack

TUniqueInstance

Opened this issue · 5 comments

How do you recommend doing the reverse procedure? If the application is already running, the previous one is closed. Optionally with the request: close the previous application or the newly launched one

I dont know

I dont know

Can I suggest the pullrequest?

It works like this:

If the TerminatePrevious flag is False (by default), then the behavior is the same as before. If set to True, it will close the previous application (additionally, the OnTerminateCommand event is created to perform user procedures before terminating the previous running application).

If you want to make a request for the user after starting the second instance: which application you want to leave running, then there is an OnQueryBeforeCheck event. In this case, the TerminatePrevious flag can be set to close the previous instance or unchecked to close the new instance as usual.

The OnAnotherInstance event should be left non-nil for the server's IPC counter to work. Theoretically, it can be done so that it is always worked, but so far it has left the behavior at most the same as it was

Example of using the new properties here. Please note that the default propertes leave the behavior of the component exactly the same as it was.

Why it might need to stop an already running app instead of a new one: update to a new version, for example. Why it might need a request before checking unique instance: if the program needs sometimes to run both applications and this requires a request from the user of the program