Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: GUI: hangs up
Date: Wed, 17 Oct 2007 15:02:33 +0000 (UTC)
Organization: Ford Motor Co
Lines: 31
Message-ID: <ff5869$jmi$1@fred.mathworks.com>
References: <fedl3p$373$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-06-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1192633353 20178 172.30.248.36 (17 Oct 2007 15:02:33 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 17 Oct 2007 15:02:33 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 35831
Xref: news.mathworks.com comp.soft-sys.matlab:433397



I had this problem in various versions of Matlab in many 
occations. Now I know how to deal with it.

I have an educated guess for the cause of the problem. In 
the code, after the user giving inputs through GUI, if 
there are intensive calculations need to be executed, the 
GUI windows usually freeze. I did a test. I had a dialog 
window created by questdlg() which has two buttons ("Yes" 
and "No"). If user clicks "Yes", the program do some 
intensive calculation. If user clicks "No", the program is 
ended. When I run the test, if I click "No", all seem 
nomal. If I click "Yes", the dialog window got stuck. The 
CPU usage in the task manager flares up but the CPU is not 
running my intensive calculation because if it does, there 
shall be some display in the Matlab command window. It 
took a while for the computer to get out of the freezed 
window and start to run the intensive calculation. 

So the problem is that the computer doesn't have enough 
time to refresh the GUI. Sometimes, I started to click 
other windows of other application such as IE, Word, etc. 
which makes it worse. In some cases, I can't wait any 
longer so I just kill the Matlab application.

There are suggestions that adding a "drawnow" statement 
after the GUI function (questdlg() statement in my case) 
could solve the problem. I tried but it didn't work well.

My solution is to add a pause(0.2) statement instead of 
drawnow statement. It works every time.