- use a much smaller time like pause(0.001)
- or use drawnow instead of pause. Drawnow allows interruption but doesn't wait. It's like pause with the smallest waiting value possible
Give priority to gui callback over code
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Guillaume Penderia
el 25 de Jul. de 2017
Editada: Walter Roberson
el 26 de Jul. de 2017
Hi,
I'm having some issues right now that I would need to be sorted. Here is the situation :
I need to monitor some data, and I want to do it through an interface. (I used the app designer functions)
I have a main program, and an interface which should display some data from the main running program.
The function to generate the interface is called from the main program so that it can have access to the handles.
In order to disturb the main program as little as possible, I put a "Refresh" button on the interface. The "refresh" callback function is nested in the main program. This function updates all the fields of the interface so that it shows the updated data from the main program.
Since I'm starting with some tests, I did this at first :
tic;
while toc < 30
value = toc;
pause(1);
end
With this first test, the refresh button works, my value is displayed in the interface as expected.
But then, I did this :
tic;
while toc < 30
value = toc;
end
Now, clicking on the button will not trigger any change in the interface. It seems that the callback nevers runs until I terminate the program.
Is there any way I can get that fixed ? I cannot afford to leave this "pause" function since the actual main program is supposed to monitor animal behaviour...
0 comentarios
Respuesta aceptada
Titus Edelhofer
el 25 de Jul. de 2017
Hi,
the pause allows interruption of the code, so yes, it is needed. You can
Titus
5 comentarios
Titus Edelhofer
el 26 de Jul. de 2017
Hi Guillaume, your welcome. Yes, pause(0) has the same effect with the advantage of not watching out for redrawing of any graphics. Therefore it could be indeed faster, thanks for the reminder :)
Walter Roberson
el 26 de Jul. de 2017
Editada: Walter Roberson
el 26 de Jul. de 2017
I do not seem to see any documentation that pause(0) treats the event queue or graphics any differently;
https://www.mathworks.com/help/matlab/ref/pause.html#butxu5w-2 says that graphics updates and callbacks keep running
"When an object's Interruptible property is set to 'on', its callback can be interrupted at the next occurrence of one of these commands: drawnow, figure, getframe, waitfor, or pause.
If the running callback contains one of these commands, then MATLAB stops the execution of the running callback and executes the interrupting callback. MATLAB resumes executing the running callback when the interrupting callback completes."
which says nothing about pause(0) being special.
Más respuestas (0)
Ver también
Categorías
Más información sobre Code Execution en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!