I found a different solution which appears to work nicely: https://undocumentedmatlab.com/blog/matlab-and-the-event-dispatch-thread-edt
I don't understand the blog post details but below is what I am using based on the callbackOnEDTQueue() function referenced at the end of the post.
so now in initialize:
obj.L3 = addlistener(axes_handle.XRuler,'MarkedClean',@(~,~)obj.xrulerMarkedClean);
obj.callback_obj = handle(com.mathworks.jmi.Callback,'callbackProperties');
set(obj.callback_obj,'delayedCallback',@(~,~)obj.renderDataCallback());
xRulerMarkerClean
if isequal(obj.last_processed_xlim,get(obj.axes_handle,'XLim'))
return
end
obj.throwCallbackOnEDT();
throwCallbackOnEDT()
%Some logging not shown, but the main call is:
obj.callback_obj.postCallback();
4 Comments
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/368964-queue-addlistener-events-or-place-event-on-edt#comment_509314
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/368964-queue-addlistener-events-or-place-event-on-edt#comment_509314
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/368964-queue-addlistener-events-or-place-event-on-edt#comment_509321
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/368964-queue-addlistener-events-or-place-event-on-edt#comment_509321
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/368964-queue-addlistener-events-or-place-event-on-edt#comment_509354
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/368964-queue-addlistener-events-or-place-event-on-edt#comment_509354
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/368964-queue-addlistener-events-or-place-event-on-edt#comment_523075
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/368964-queue-addlistener-events-or-place-event-on-edt#comment_523075
Sign in to comment.