So I know because of the Question Can Timers get automatically garbage collected? that the System.Timers.Timer
will not be garbage collected in the first place.
But my actual question is - do i have to stop or dispose the Timer?
private void CreateTimer()
{
var timer = new Timer();
timer.Elapsed += TimerElapsed;
timer.Interval = 30000;
timer.AutoReset = true;
timer.Enabled = true;
}
I mean this Timer will run forever. But now I have no need anymore for my object that created the Timer in the Method. Do I have to stop or dispose the Timer
that it gets garbage collected?