Preventing parallel GUI functions from overrunning matlab
显示 更早的评论
Hello! I've run into a brick wall, and I believe that it's because I don't understand how matlab handles parallel functions.
First of all, lets say that I have a GUI with a single button in the middle
figure1 = figure; button1 = uicontrol('style','pushbutton','position',[.5 .5 .5 .5]);
And lets say that this button's callback function opens up a new figure to say, change the color of the figure background with another function that I've written.
set(button1,'callback',@changeBkgrdColor)
Now, if the user clicks on the button again without ending the changebkgrdColor function, it'll open up a second instance of my changeBkgrdColor function.
If you're looking to crash matlab, you can open up about 30 parallel functions and from that point, no more functions will open, matlab freaks, and the only way to fix it is to ctrl+c on the command line or end matlab's process.
Is there a way to break out of a function with something like a handle reference?
采纳的回答
更多回答(1 个)
per isakson
2014-6-9
编辑:per isakson
2014-6-10
Interruptible
{on} | off
Callback routine interruption mode. Controls whether a object
callback function can be interrupted by subsequently invoked
callbacks.
.
In response to comments:
.
Try
uicontrol( 'Callback', 'interrupt_test' ...
, 'Interruptible', 'off' ...
, 'BusyAction', 'queue' )
and
uicontrol( 'Callback', 'interrupt_test' ...
, 'Interruptible', 'off' ...
, 'BusyAction', 'cancel' )
where
function interrupt_test
fprintf('responding at: %s\n', datestr( now, 'MM:SS.FFF') )
pause( 2 )
end
3 个评论
Charles Miller
2014-6-10
Charles Miller
2014-6-10
per isakson
2014-6-10
编辑:per isakson
2014-6-10
"which might be the problem" . What problem do you refer to?
I added an example to my answer
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB Parallel Server 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!