How to break a running function in an App Designer app?
Show older comments
I have a button in app designer that calls a function, which can sometimes take 15+ min to return. I'd like to have a second button which breaks the function call of the first so that I can change other UI elements and start the call over. What's the best way to do this?
Answers (1)
Ctrl+C should abort the function call without aborting the app.
If that's not graceful enough, you will need to modify whatever loop button #1 is running so that it periodically check the state of some app property controlled by button #2.
6 Comments
qmnjb007
on 15 Jan 2018
Matt J
on 15 Jan 2018
According to this, no
However, I don't understand the part where you wrote "that would simply prevent the function from being called again if "break" criteria were detected". You would just need to reset the break flag at some point before attempting to rerun.
qmnjb007
on 16 Jan 2018
qmnjb007
on 16 Jan 2018
I mean, pass the variable called "app" to sim_year as an optional 5th argument,
x = sim_year(app.in_it, slr_cur, batt_cur, app.b_chrg, app);
That way, sim_year will have access to everything that app does.
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!