Do MATLAB GUI buttons create parallel strands if pressed multiple times?
이전 댓글 표시
So i have a GUI with a button to gather data from a USB device. when pressed the button triggers a sequential code to recover data from the device.
My question is, could multiple presses trigger multiple instances of the same code to run either deliberately or through the absence of a particular code to prevent it?
If so, and it affects the displayed figure, which process has priority?
Thanks,
Jason
답변 (2개)
Walter Roberson
2017년 9월 18일
0 개 추천
You would need to have specific use of the Parallel Computing Toolbox such as parfor() or spmd() or parfeval() in order to have multiple parallel instances of the same code.
However in some cases it is possible for a callback to suspend a different callback. See the description of https://www.mathworks.com/help/matlab/ref/uicontrol-properties.html#zmw57dd0e1042342 the Interruptible and BusyAction properties.
Jason Riley
2017년 9월 18일
0 개 추천
댓글 수: 4
Walter Roberson
2017년 9월 18일
The first would be suspended.
Note that there are limited circumstances in which the interrupt can be be considered for service: pause(), waitfor(), uiwait(), figure(), drawnow(), keyboard(). If you do not have those in your code then MATLAB will just queue the event without any checks until it is allowed to look at the queue to process the Interruptible BusyAction test
Walter Roberson
2017년 9월 18일
It has never been really clear under what conditions a listener can fire, or a serial or instrument or daq callback can fire. Buried somewhere in the documentation is a note a couple of years ago that timers can be serviced every source line, which is an exception to the drawnow / pause rule.
Jason Riley
2017년 9월 18일
Walter Roberson
2017년 9월 20일
Disabling the button is a good idea.
카테고리
도움말 센터 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!