title: Garbage collection of C# object declared in constructor
body: <p>In the following code, I create a DispatcherTimer in the class's constructor. No one keeps reference on it.</p>
  
  <p>In my understanding, the timer should be reclaimed by the garbage collector some time after leaving the constructor's scope. 
  But that doesn't happen! Even after forcing a garbage collection with <code>GC.Collect()</code></p>
  
  <p>What is going on under the hood?</p>
  
  <pre><code>public partial class MainWindow : Window
  {
      public MainWindow()
      {
          InitializeComponent();
  
          new DispatcherTimer
          {
              Interval = TimeSpan.FromMilliseconds(100),
              IsEnabled = true
          }
          .Tick += (s, e) =&gt;
          {
              textBlock1.Text = DateTime.Now.ToString();
          };
      }
  }
  </code></pre>