필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Brad
Brad 2013년 1월 2일
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

답변 (1개)

Sean de Wolski
Sean de Wolski 2013년 1월 2일
편집: Sean de Wolski 2013년 1월 2일
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.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by