Order of code execution seems weird

조회 수: 2 (최근 30일)
Nico
Nico 2023년 11월 16일
댓글: Nico 2023년 11월 16일
I have built an app that executes long functions. In my GUI I have something like a MessageWindow (Colored-Edit-Field). When clicking a button to calculate something that takes a while I want to show a Message like: "LOADING. . ." The according code is shown below.
When I execute the code by clicking the button, the Message is not shown. The calculation function ist executed though.
When I step through my code with the debugger line by line, it works fine. So for me it seems like MATLAB ist not executing the code in the correct order. Can somone explain me what the problem could be here?
%% Function in app.PlotSetup
function printProcess(app, message)
app.StatusEditField.BackgroundColor = app.yellow;
app.StatusEditField.Value = message;
end
%% Code in app.Plotting
% Function to show message
printProcess(app.PlotSetup, "LOADING WITH SELECTED PARAMETERS...")
% Big calculation function
continueImportProcess(app.PlotSetup)
  댓글 수: 1
Jon
Jon 2023년 11월 16일
Would it be possible for you to make a self contained example that reproduces the problem and attach it?

댓글을 달려면 로그인하십시오.

채택된 답변

Stephen23
Stephen23 2023년 11월 16일
이동: Image Analyst 2023년 11월 16일
Try calling DRAWNOW after setting the editfield values.
  댓글 수: 1
Nico
Nico 2023년 11월 16일
Thanks! Works perfectly.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Bruno Luong
Bruno Luong 2023년 11월 16일
%% Function in app.PlotSetup
function printProcess(app, message)
app.StatusEditField.BackgroundColor = app.yellow;
app.StatusEditField.Value = message;
drawnow % force GUI to refresh
end

카테고리

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

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by