title: C# disposable objects
body: <p>Are there some advices about how I should deal with the <code>IDisposable</code> object sequences?</p>
  
  <p>For example, I have a method that builds a <code>IEnumerable&lt;System.Drawing.Image&gt;</code> sequence and
  at some point I would need to dispose that objects manually, because otherwise this might lead to some leaks.</p>
  
  <p>Now, is there a way to bind the <code>Dispose()</code> call to garbage collector actions, because I want these objects disposed right in the moment they are <strong>no longer accessible</strong> from other code parts?</p>
  
  <p>**<em>Or maybe you could advice me some other approach?</em> **</p>
  
  <hr>
  
  <p>Generally, this seems to be the same problem as it comes, for example, in unmanaged <code>C++</code> without <em>shared pointers</em>, where you can have a method:</p>
  
  <pre><code>SomeObject* AllocateAndConstruct();
  </code></pre>
  
  <p>and then you can't be sure when to dispose it, if you don't use code contracts or don't state something in the comments.</p>
  
  <p>I guess the situation with disposable objects is pretty the same, but I hope there is an appropriate solution for this.</p>