Excuting event listeners asynchronously
Afficher commentaires plus anciens
Please run below
hedt = uicontrol('Style','edit','Callback',@edt_callback);
addlistener(hedt, 'String', 'PostSet', @listener_1);
addlistener(hedt, 'String', 'PostSet', @listener_2);
addlistener(hedt, 'String', 'PostSet', @listener_3);
function edt_callback(~,~)
disp('edt callback ends')
end
function listener_1(~,~)
pause(1)
disp('listener 1 ends')
end
function listener_2(~,~)
pause(2)
disp('listener 2 ends')
end
function listener_3(~,~)
pause(3)
disp('listener 3 ends')
end
it takes ~6 second and listener_3 results first, which has longest pause time.
>> test_script
listener 3 ends
listener 2 ends
listener 1 ends
edt callback ends
so, obviously, all listeners linked to a event shall be excuted in serial (on by one) in Matlab.
I hope to run all listeners asynchronously, i.e. in seperated thread.
what would be my option?
Thank you.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Entering Commands dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


