Effacer les filtres
Effacer les filtres

Listdlg freezes but not when debugged; using pause seems to fix

2 vues (au cours des 30 derniers jours)
Brad
Brad le 2 Jan 2013
I am using matlab R2012B, and using listdlg to allow the user to select which channels need to be processed:
[s,v] = listdlg('PromptString', 'Select Channels to Display',...
'SelectionMode', 'multiple', 'Name','Channel Selection',...
'ListString', handles.DAQ_info.Ch_Names, 'InitialValue', handles.channels);
Sometimes the dialog box would freeze and other times it would work fine. Everytime I would place a debug at or after it there wouldn't be a problem. As a work around I placed a pause(1/4) after it and everything seems to work fine now. Just wondered if anyone has had this issue or knows why this is occuring.
Thanks
Brad

Réponses (1)

Sean de Wolski
Sean de Wolski le 2 Jan 2013
Modifié(e) : Sean de Wolski le 2 Jan 2013
This is expected. One of the features of pause() is that it flushes the event queue so any pending events are taken care of before the code continues. This is the sole purpose of drawnow() so I recommend using drawnow() instead.
The reason it is hanging is because all of the events build up. Matt and I discussed this here: Old Answer
This also explains why debugging works - when you debug, MATLAB has plenty of time before showing you the debugger to flush any remaining events. Doug likes to call this a Heisenbug, which I kind of like.

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by