问题
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