watcher
is a local variable, but that doesn't affect the object necessarily. You've asked the GeoCoordinateWatcher
to start - I'd expect it to maintain a reference to itself, effectively, or stash one somewhere appropriate.
It sounds like either you ought to disable the button once it's clicked, or you need to keep the watcher in an instance variable so that you can dispose of the old one and create a new one. (I'm not sure why that would be useful though.)
EDIT: As there are two incorrect answers here, let me just clear something up... an event publisher (the watcher in this case) has references to the handler delegates. If those delegates refer to instance methods (as it does in this case) then there's a reference to an instance of the type containing that method:
Event publisher => delegate => instance of type with handler method
That means that as long as the publisher isn't garbage collected (and the event handler still exists), the instance associated with the delegate can't be collected. It doesn't prevent the publisher itself from being garbage collected.
In other words, if GeoCoordinateWatcher
didn't do something "special" (probably in the Start
method) it could be garbage collected. There's no implicit reference from an event handler to the event publisher which prevents it from being garbage collected that way round.