Using waitfor for non Handle Graphics Object
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I'm trying to implement a code which should wait for timer timeout or change of a specific value befor futher code's execution. I've found the following code on the web. It's exactly what I'm looking for but it doesn't work with simple matlab handle object. Do someone know what to do?
% Wait for data updates to complete (isDone = false if timeout, true if data ok)
function isDone = waitForDone(object,timeout)
% Initialize: timeout flag = false
object.setDone(false);
% Create and start the separate timeout timer thread
hTimer = timer('TimerFcn',@(h,e)object.setDone(true), 'StartDelay',timeout);
start(hTimer);
% Wait for the object property to change or for timeout, whichever comes first
waitfor(object,'Done',true);
% waitfor is over - either because of timeout or because the data changed
% To determine which, check whether the timer callback was activated
isDone = (hTimer.TasksExecuted == 0);
% Delete the time object
try stop(hTimer); catch, end
try delete(hTimer); catch, end
% Return the flag indicating whether or not timeout was reached
end % waitForDone
thanks for your support!
Bolivar
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!