Path: news.mathworks.com!not-for-mail
From: "Adam " <not.my.email@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Tempoarily Disable a GUI while a function is running
Date: Tue, 11 Sep 2007 21:35:10 +0000 (UTC)
Organization: Atlantic Inertial Systems
Lines: 25
Message-ID: <fc71me$ouq$1@fred.mathworks.com>
Reply-To: "Adam " <not.my.email@mathworks.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1189546510 25562 172.30.248.37 (11 Sep 2007 21:35:10 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 11 Sep 2007 21:35:10 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1091020
Xref: news.mathworks.com comp.soft-sys.matlab:427962


I have a complicated function that take awhile to run.  I
have set up a GUI using GUIDE to handle different variables.
 The problem I have is the user can click the run button, or
a slider control multiple times.  This calls multiple
instances of the function, with bizarre results.  In a
couple cases enough functions are called to crash Matlab.

I tried making the waitbar() modal.  However, you can still
sneak in 2-3 button presses.  Even worse, if you click a
slider control it locks and then proceeds to repeatedly push
the slider button (calling a function instance every time)
until it reaches the max limit!!!

I'm pretty sure the following code will work:
    set(hObject, 'Enable', 'off')
    
    set(handles.lblWait, 'String', 'Thinking ...')
    pause(0.01)
    fcnTestPlot(fVal, handles);   % <-- this is "long" fcn

    pause(0.01)
    set(handles.lblWait, 'String', '')
    set(hObject, 'Enable', 'on')

 It seems like a bit of a hack; i.e. is there a better way?