How do I make a function which is not a GUI callback uninterruptible?

I am running a GUI based asynchronous code. I have some functions that are called in the code but are not direct callbacks of any GUI object, but are called by events and timers. I would like to make sure that one of these functions is not interrupted by any of the others and that all other functions will be queued until this one has finished.

1 个评论

The queuing bit is not trivial. I generally only have situations where I need to reject new function calls. To do that, you can use the appdata to store a busy flag (which you can even set to the groot instead of a figure):
setappdata(groot,'LongNameToAvoidConflicts',1)
But that doesn't really help you in queuing.

请先登录,再进行评论。

回答(1 个)

Here is an idea (untested, but it might work): define a simple GUI object (e.g. a uicontrol push button) that calls the uninterruptible functions. Set its 'Interruptible' and 'Visible' properties to 'off'. When you want to run the uninterruptible function, get the timer/... to change some property of the object (e.g. the value). This will trigger the callback, which hopefully then runs without interruption....
If that does not work then do the same with a listener:

类别

在 帮助中心 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by