Question: I have a question regarding something I'm seeing in some VB.NET code on a project that I've had to take over. In a form the developer has declared a very simple 15sec timer.

```
Private WithEvents mtmrManualDecision As New System.Timers.Timer(15000)

```

Now, I know that this timer will trigger the mtmrManualDecision\_Elapsed event each 15 seconds after it has been started via mtmrManualDecision.Start(). I'm also familiar with stopping this timer via mtmrManualDecision.Stop(). However, I'm seeing this line of code in parts of the form (like when a button is clicked or the form is closed).

```
RemoveHandler mtmrEvaluation.Elapsed, AddressOf mtmrEvaluation_Elapsed

```

I believe this is basically stopping the timer. Why do this instead of just stop? It's not being added back or used again after this so I'm wondering why the need to do this. I don't normally use RemoveHandler unless I actually used AddHandler in my own code. I believe that the declaration of the timer using "WithEvents" automatically adds a handler for the Elapsed event and he just wants to remove it. Is this really necessary and wouldn't the garbage collection take care of removing the handler like it does with other events, etc.)?

Any clarification or ideas would be appreciated. Thank you very much.

Answer: 
> 
> I believe this is basically stopping the timer.
> 
> 
> 

No, it does not stop the timer. The timer does not stop until your program stops it, or disposes of it. Once you remove the handler, the timer will stop delivering the events to your program, but it would continue "ticking" in the background.

For example, if you remove the handler 3 seconds into the 15-second interval, and then add it back 2 seconds later, you will get an event after 10 more seconds (3 + 2 + 10 = 15).

One reason to remove a handler is to let its associated object, if any, become eligible for garbage collection. This prevents a "lingerer" memory leak. For example, consider a timer that produces an object, and stores it into a list associated with another object, which is owned by your main program. Let's say that at some point your main program drops the object hosting the list. However, the list may not become eligible for garbage collection if the event handler keeps a strong reference to the object. Unregistering for the event explicitly is one way of addressing this problem; another way is to use a [Weak Event Pattern](http://msdn.microsoft.com/en-us/library/aa970850%28v=vs.110%29.aspx).
> 
> I believe this is basically stopping the timer
> 
> 
> 

No, it's removing a single handler. If there are any *other* handlers, those will keep firing. Or maybe the developer wants to be able to re-add the handler later on, with the timer keeping going with its original schedule (rather than stopping/starting which will change the schedule).

You haven't really provided us enough information to get into the head of the original developer, but these are just examples of why removing a handler from a timer *isn't* the same as stopping it.