title: How to access DirectoryInfo.EnumerateFiles before it has completed
body: <p>In the question I asked <a href="https://stackoverflow.com/questions/10604830/retrieve-a-list-of-filenames-in-folder-and-all-subfolders-quickly">Retrieve a list of filenames in folder and all subfolders quickly</a> And a few others I have found, it seems the way to search many files is to use the EnumerateFiles Method. </p>
  
  <blockquote>
    <p>The EnumerateFiles and GetFiles methods differ as follows: When you
    use EnumerateFiles, you can start enumerating the collection of names
    before the whole collection is returned;  when you use GetFiles, you
    must wait for the whole array of names to be returned before you can
    access the array. Therefore, when you are working with many files and
    directories,  EnumerateFiles can be more efficient.</p>
  </blockquote>
  
  <p>This sounds Great for me, my search is taking about 10 seconds, so I can start makign my list as the information comes in.  But I can't figure it out.  When I run the EnumerateFiles Method, the application freezes until it completes.  I could run it in a background worker, but the same thing will happen to that thread.  Any help?</p>
  
  <pre><code> DirectoryInfo dir = new DirectoryInfo(MainFolder);
   List&lt;FileInfo&gt; matches = new List&lt;FileInfo&gt;(dir.EnumerateFiles("*.docx",SearchOption.AllDirectories));
  
  //This wont fire until after the entire collection is complete
  DoSoemthingWhileWaiting();
  </code></pre>