Trying to launch external (flatpak) app on Pi with Shell asynchronous. It only works if I have a messagebox after execute

Hi All. I am very new to Xojo. I am trying to launch an flatpak (sandboxed) app with Xojo. In order for it not to pause my app I am launching it mode 1. The app only launches if I have a messagebox right after the .execute:

sh.ExecuteMode = Shell.ExecuteModes.aSynchronous
sh.Execute("/usr/bin/flatpak run myapplication &")
messagebox("")
'This works and myapplication  launches
sh.ExecuteMode = Shell.ExecuteModes.aSynchronous
sh.Execute("/usr/bin/flatpak run myapplication &")
'This does nothing

I don’t need anything back from the application, I just want it to go off and do it’s own thing. Any ideas?

How and where is sh defined? If in a method, sh will die when the method exits. Perhaps that kills the shell before it gets going.

Make sh a global variable.

Thanks I just tried that and it doesn’t work either. I can still only get it to work with the messagebox

Ah but I think you are right, well at least, this now works:

sh.Execute("/usr/bin/flatpak run myapplication &")
thread.SleepCurrent (500)

Thank you. This has taken me ages and it was so simple