Using waitfor for non Handle Graphics Object
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!