필터 지우기
필터 지우기

Using waitfor for non Handle Graphics Object

조회 수: 1 (최근 30일)
Bolivar
Bolivar 2013년 7월 31일
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개)

카테고리

Help CenterFile Exchange에서 Security에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by