Borrar filtros
Borrar filtros

Deleting Timer Objects containing in Objects' properties

4 visualizaciones (últimos 30 días)
Hello,
ich have been trying to delete Timer Object, stored in Object's property before destroying the concerned object. But the Object is deleted and the Timer not. Then any try to delete the timers with help of built-in function "delete" cause matlab to crash. I'm using the following code:
properties
timerCall
end
the Timers' parameter are initialized in constructor. The delete function look like this:
methods
function delete(obj)
delete(obj.timerCall);
end
end
What am I doing wrong? can someone help me?
thanks

Respuesta aceptada

Image Analyst
Image Analyst el 10 de Jul. de 2013
See if my code to kill all timers works for you:
%--------------------------------------------------------------------------------------------------------------------------
function StopTimer(handles)
try
fprintf('Entering StopTimer...\n');
listOfTimers = timerfindall % List all timers, just for info.
% Get handle to the one timer that we should have.
if isempty(listOfTimers)
% Exit if there is no timer to turn off.
fprintf('There are no timers to turn off. Leaving StopTimer().\n');
return;
end
handleToTimer = getappdata(handles.figMainWindow, 'timerObj');
% Stop that timer.
stop(handleToTimer);
% Delete all timers from memory.
listOfTimers = timerfindall
if ~isempty(listOfTimers)
delete(listOfTimers(:));
end
fprintf('Left StopTimer and turned off all timers.\n');
catch ME
errorMessage = sprintf('Error in StopTimer().\nThe error reported by MATLAB is:\n\n%s', ME.message);
fprintf('%s\n', errorMessage);
uiwait(warndlg(errorMessage));
end
return; % from btnStopTimer_Callback

Más respuestas (1)

Bolivar
Bolivar el 24 de Jul. de 2013
Hi, your code works properly. In fact it's excellent. But, I made the mistake using lots of handle in my programm, which was paced amoong different user. Moreover I didn't delete timers after they 've expired what i should after the documentation. Wherefore my problem. Nevertheless I've manage to solve this. Anyway thanks for your support

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by