title: Dispatcher.beginInvoke causes memory leak
body: <pre><code>    void worker_DoWork(object sender, DoWorkEventArgs e)
      {
          Action act = (Action)(() =&gt;
          {
              Thread.Sleep(1000);
              RRect r = new RRect(rnd.Next(100, 100), rnd.Next(100, 100), GetMousePosition(), PickBrush(), 1080);
              this.mainGrid.Children.Add(r);
          });
  
          while (true)
          {
              this.Dispatcher.BeginInvoke(act, DispatcherPriority.Input);
          }
      }
  </code></pre>
  
  <p>with background worker, I want to add a rectangle to my main grid every one second. I have to use this.Dispatcher.BeginInvoke because of avoiding lock. My question is that  </p>
  
  <pre><code>this.Dispatcher.BeginInvoke(act, DispatcherPriority.Input); 
  </code></pre>
  
  <p>code block causes <strong>a huge memory leak</strong>. What's wrong with it?</p>
  
  <p><strong>EDIT 1 :</strong> </p>
  
  <p>When I delete </p>
  
  <pre><code>Thread.Sleep(1000);          
  RRect r = new RRect(rnd.Next(100, 100), rnd.Next(100, 100), GetMousePosition(), PickBrush(), 1080);           
  this.mainGrid.Children.Add(r);
  </code></pre>
  
  <p>Nothing changes.</p>