フィルターのクリア

Deleting Timer Objects containing in Objects' properties

4 ビュー (過去 30 日間)
Bolivar
Bolivar 2013 年 7 月 10 日
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

採用された回答

Image Analyst
Image Analyst 2013 年 7 月 10 日
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
  1 件のコメント
Muthu Annamalai
Muthu Annamalai 2013 年 7 月 10 日
Nice function. Who knew!

サインインしてコメントする。

その他の回答 (1 件)

Bolivar
Bolivar 2013 年 7 月 24 日
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

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by