title: How do I dispose this code properly?
body: <p>I have a quite large project which I try to keep as clean and tidy as possible. When I run the code analyzer in Visual Studio I get a reliability error which I find quite annoying. I'd really like to learn how to work around it. Here is a simplified example of what I am doing.</p>
  
  <p>Here is the warning.</p>
  
  <p><em>Warning    1   CA2000 : Microsoft.Reliability : In method 'MyExampleClassForStackOverflow.AddFeed(string)', call System.IDisposable.Dispose on object 'new FeedClassExamle()' before all references to it are out of scope.</em></p>
  
  <p>Here is my example code:</p>
  
  <pre><code>class MyExampleClassForStackOverflow : IDisposable
  {
      public ConcurrentDictionary&lt;string, FeedClassExamle&gt; Feeds { get; set; }
  
      public void AddFeed(string id)
      {
          //The warning is coming from this code block.
          //In the full code, the feed classes collects data on a specific 
          //interval and feeds them back using events.
          //I have a bunch of them and they need to be accessible so I 
          //store them in dictionaries using keys to effeciently find them.
          Feeds.TryAdd(id, new FeedClassExamle());
          Feeds[id].Start();
      }
      public void Dispose()
      {
          foreach (var item in Feeds)
              item.Value.Dispose();
      }
  }
  
  class FeedClassExamle : IDisposable
  {
      public void Start()
      {
  
      }
      public void Dispose()
      {
  
      }
  }
  </code></pre>
  
  <p>In order to test the code, use:</p>
  
  <pre><code>using (var example = new MyExampleClassForStackOverflow())
  {
  
  }
  </code></pre>
  
  <p>Any suggestion would be welcome.</p>