MATLAB Answers

How do I create an app that only allows one instance of itself to run?

3 views (last 30 days)
If I run my app created in app designer, the GUI launches and If I re-run my app again, another GUI window opens. I want to make sure only single GUI window is open at a time. Meaning, if my GUI window is open, I do not want to open another window until the initial window is closed. Is this possible with the app designer?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 22 Oct 2021
Edited: MathWorks Support Team on 26 Oct 2021
In GUIDE, you can check the option "GUI allows only one instance to run" from within the GUI Options dialog. This is described in more detail on this documentation page: 
In AppDesigner, if you are using R2020b or later releases, you can select whether your app can run multiple instances at a time or only a single instance.
To change the run behavior of your app, select the App node from the Component Browser. Then, from the Code Options section of the Inspector tab, select or clear Single Running Instance.
When Single Running Instance is selected and you run the app multiple times, MATLAB reuses the existing instance and brings it to the front rather than creating a new one. When Single Running Instance is not selected, then a new app instance is created each time you run it, while existing instances of the app also continue to run.
You can see the details in the following URL page: 

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!