Uninterruptible GUI Callback without User Input

6 views (last 30 days)
I made a GUI with GUIDE which, when a button is pressed, triggers an interruptible callback (named C1) that runs a while loop until an exit condition is met. In the while loop, there is a section of code that once started must run to completion without interruption. If the callback is interrupted while executing this code, the interrupting callback must be executed after the code has finished.
I've tried using the waitfor function but it doesn't work as needed in the case of callbacks. I've also tried making an uninterruptible callback (named C2) run the important code and calling that C2 from within the while loop of C1, but it seems C2 is still interruptible unless triggered by a click event on its button from the user.
Is there a way to make a function or section of code uninterruptible and triggered by code as opposed to user input?

Answers (1)

Walter Roberson
Walter Roberson on 7 Feb 2018
You can set the uicontrol Interruptible property to 'off' and 'BusyAction' to 'queue'
Or, you can set all buttons to 'Enable', 'disable' while running the critical routine.
Instead of having to know about all other buttons to change their Enable properties, you can also put the critical button inside a figure whose 'WindowStyle' is set to 'modal' (and set that one object to Interruptible off or set that one button Enable 'disable' during the critical action.)
  1 Comment
Biraj Khanal
Biraj Khanal on 19 Jan 2022
I tried and saw that Interruptible and Busyaction do help when you use buttons.
The uicontrol do not help when it comes to something like a cellEdit of a table. While editing a cell, if you triger another function like cellselection of another table, it simply switches the flow to the trigerred function without completing the celledit first.
Do you have any suggestion?
Not sure if this is legal here but I here is a link to the detail of my question.
https://de.mathworks.com/matlabcentral/answers/1630540-complete-executing-celledit-before-any-other-function-is-trigerred

Sign in to comment.

Categories

Find more on Migrate GUIDE Apps 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!