If the autoreset is set to false, will my timer be disposed automatically?

筅森魡賤 提交于 2019-12-13 14:26:57

问题


I launch a timer only one time in my application:

CustomTimer timer = new CustomTimer(mod);
timer.Interval = interval.TotalMilliseconds;
timer.AutoReset = false;
timer.Start();

So the AutoReset is set to false. At the end of the timer, will the dispose method be called automatically?


回答1:


No it will not. AutoReset will simply state whether the Elapsed event should be triggered each time the interval elapses, or only the first time.

You can e.g. hook up an event handler to the Tick event and do whatever disposing you need to.




回答2:


No, The timer just will not Reset back to zero. The resources used for the timer wil still be used because the reference to the object still exists.



来源:https://stackoverflow.com/questions/3829036/if-the-autoreset-is-set-to-false-will-my-timer-be-disposed-automatically

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!