Using waitfor for non Handle Graphics Object

1 visualizzazione (ultimi 30 giorni)
Bolivar
Bolivar il 31 Lug 2013
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

Risposte (0)

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by