title: How do I report progress while executing a LINQ expression on a large-ish data set
body: <p>If I need generate a fairly large dataset using LINQ and it may take a while (say a few seconds) and I need to (would like to) generate feedback to the use as to %'age done, is there an easy/ preferred way to do this?</p>
  
  <p>Example, say I have list A with 1000 cars and list B with 1000 trucks and I want to select all possible ordered (car, truck) pairs where car.color == truck.color link this:</p>
  
  <pre><code>var pairs = from car in A 
              from truck in B 
              where car.color==truck.color 
              select new {car, truck};
  </code></pre>
  
  <p>Now at some point this will be evaluated as a set of nested foreach loops.  I would like to be able to report %'age complete as it interates and ideally update a progressbar or something.  </p>
  
  <p>EDIT: Just after my query, I store the result in a member variable as a list like this (which forces the query to execute):</p>
  
  <pre><code>mPairs = pairs.ToList();
  </code></pre>
  
  <p>I do this because I am executing this in a background worker thread as I do not want the UI thread to freeze up as it evaluates the LINQ expression on demand on the UI thread (this is in Silverlight BTW).  Hence why I would like to report progress.  The UX is basically this:</p>
  
  <ol>
  <li>A user drags an item onto the workspace</li>
  <li>The engine then kicks up on a background thread to determine the (many) connection possibilities to all of the other items on the workspace.</li>
  <li>While the engine is calculating the UI does not allow new connections AND reports progress to indicate when the new item will be "connectable" to the other items (all the possible connection paths not already in use have been determined via LINQ).</li>
  <li>When the engine completes the calculation (query), the item is connectable in the UI and the possible connection paths are stored in a local variable for future use (e.g. when the user clicks to connect the item all the possible paths will be highlighted based upon what was calculated when it was added)</li>
  </ol>
  
  <p>(a similar process must happen on deletion of an item)</p>