In timer class, reach the ErrorFcn when there is no Queue
7 views (last 30 days)
Show older comments
I create a timer class with the BusyMode 'error'. I set the period 1sec and TasksToExecute twice. The TimerFcn pause 1.6sec. The timerfcn should be called at time 0sec and 1sec. And in 1sec, the Queue is empty. The timefcn can only be called twice. Therefore I did see why in the end the Errorfcn is called. Below is the code.
function mytimer()
t = timer;
t.Period = 1;
t.ExecutionMode = 'fixedRate';
t.TimerFcn = @mytimer_cb;
t.ErrorFcn = @myerror;
t.BusyMode = 'error';
t.TasksToExecute = 2;
t.UserData = tic;
start(t)
end
function mytimer_cb(h,~)
timeStart = toc(h.UserData)
pause(1.6);
timeEnd = toc(h.UserData)
end
function myerror(h,~)
disp('Reached the error function')
end
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!