PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → [WD20] Avoiding "This application cannot be launched several times."
[WD20] Avoiding "This application cannot be launched several times."
Débuté par Curtis, 11 aoû. 2017 19:49 - 5 réponses
Posté le 11 août 2017 - 19:49
Cette application ne peut pas etre lancee plusieurs fois. This application cannot be launched several times.
I'm trying to avoid the above error. It happens when I exit my app, and try to relaunch it right away. It seems my app is taking some time to completely stop running.

To exit the app I use EndProgram(). The only closing code that runs is disconnecting 3 or 4 serial connections and closing an extra sister window that displays on a different monitor. I just commented out the closing code and generated a new exe. I still have the same problem.

Any suggestions?
Posté le 11 août 2017 - 21:52
Hiya, when you re creating the exe isn't there an option saying something like, 'only allow one instance to be running at once' maybe you have that ticked? As I have no problems running multiple instances of the same exe.

ISO
Posté le 11 août 2017 - 21:57
That is correct. However I would like to continue to disallow our users from opening multiple instances.
Posté le 14 août 2017 - 10:48
Hi Curtis,

Set the project to allow 'multiple instances' to run - and then use the code in the project opening event to control the number of instances allowed and the message that is given to the user.

IF ExeRunning() > 1 THEN Info("Only one instance of the application can be run at a time.") EndProgram(True) END
Thanks
Ned!
Posté le 14 août 2017 - 15:13
Hi Curtis,

here is no way to avoid that problem completely, as you are saying that you are trying to relaunch the app BEFORE it is completely unloaded.

But maybe you can mitigate the problem by first opening a "Wait, closing operations in process..." free window with no code in it and by closing that window as the last line of project closing code (Not sure it will work)

A more complex solution would be to have a secondary exe that you run first (and that exe displays the message). In it a timer checks in memory is the main exe is still there and closes itself only when it's not anymore. At that point, the user can restart the program.

Of course, the user can still start the program too early, but there is a window right there to tell him that he is a dummy :-)

Best regards
Posté le 14 août 2017 - 17:45
Thanks y'all! I'm going to go with Ned's solution.