How can check if GUI fully created?

1 visualización (últimos 30 días)
Eduard Mazur
Eduard Mazur el 16 de Jun. de 2021
Respondida: Sameer el 21 de Mayo de 2024
Hello all,
So I have an app which create additional tabs with content(tables, plots etc.) somewhere in the middle of process. I have cover this code with progress dialog, but after this dialog dissapear it takes for app litterally additional ~5min to actual make this elements fully availiable.
So my question: Is it possible somehow check if app finish their routine or not?

Respuestas (1)

Sameer
Sameer el 21 de Mayo de 2024
Hi Eduard
From my understanding, you are developing a MATLAB GUI application that involves long-running operations for generating and displaying content in new tabs, such as tables and plots. After showing a progress dialog, your application takes a significant amount of time (~5 minutes) to make these elements fully available. You want to achieve a way to programmatically determine when these operations have completed to enhance the user experience, ensuring the application only proceeds or notifies the user once all elements are ready for interaction.
Below are several strategies that can be employed to monitor task completion within an application:
1. Utilizing Callbacks
For architectures that support asynchronous operations, implementing callback functions offers a direct method to signal task completion. By initiating a long-running task with an associated callback function, the application can receive a clear notification upon the task's completion, allowing for precise control over subsequent actions.
2. Employing Polling with a Timer
In situations where callback functions are not applicable, leveraging a MATLAB timer object to periodically check the status of a task can be effective. This method involves maintaining a flag or status variable that represents the task's completion state, with a timer periodically assessing this variable to determine the task's progress.
Example Implementation:
function startLongOperation()
global isOperationComplete;
isOperationComplete = false;
% Simulate a long-running operation
t = timer('TimerFcn', @endLongOperation, 'StartDelay', 5);
start(t);
% Timer to monitor operation status
checkTimer = timer('TimerFcn', @checkOperationStatus, 'Period', 1, 'ExecutionMode', 'fixedRate');
start(checkTimer);
end
function endLongOperation(~, ~)
global isOperationComplete;
isOperationComplete = true;
disp('Long operation finished.');
end
function checkOperationStatus(~, ~)
global isOperationComplete;
if isOperationComplete
disp('Operation is complete. Proceeding with the rest of the application.');
else
disp('Operation still in progress...');
end
end
This setup initiates a long operation and employs a polling mechanism to monitor its completion, allowing for appropriate actions to be taken once the task is finished.
3. Incorporating Event Listeners
Applications structured around MATLAB App Designer or class-based GUIs can benefit from the integration of event listeners. By defining custom events associated with long-running tasks and triggering these events upon task completion, different components of the application can respond to these events, facilitating synchronized operations.
4. Setting Busy Flags
A more straightforward approach involves the use of a "busy" flag or variable, set at the commencement of a long operation and cleared upon its completion. This flag serves as an indicator for the application to either pause further actions or proceed, based on the operation's status.
The choice of strategy largely depends on the specific structure of the application and the nature of the tasks involved.
Please refer to the below links for more information:
I hope this helps!
Sameer

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by