Possible Duplicate:
Do event handlers stop garbage collection from occuring?
I had one wp7 application like this:
private void button1_Click(object sender, RoutedEventArgs e)
{
GeoCoordinateWatcher watcher = new GeoCoordinateWatcher();
watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
watcher.Start();
}
void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
{
Debug.WriteLine(e.Position.Timestamp.ToString());
}
After I click the button twice,the Console will output the Timestamp twice. But the watcher was a local variable! What's wrong with it? And how can I distory it?