If I need to create a fairly large dataset using LINQ, and this may take some time (say, a few seconds), and I need (would like) to generate feedback for use with respect to% 'age done, is there a simple / preferred way to do this?
An example, let's say I have a list A with 1000 cars and a list B with 1000 trucks, and I want to select all possible ordered (automobile, freight) pairs, where car.color == truck.color link to this:
var pairs = from car in A
from truck in B
where car.color==truck.color
select new {car, truck};
Now at some point this will be evaluated as a set of nested foreach loops. I would like to be able to report the percentage of age% as it interacts and ideally updates the progress indicator or something like that.
EDIT: right after my request, I save the result in a member variable as a list like this (which forces the request to be executed):
mPairs = pairs.ToList();
I am doing this because I am doing this in the background workflow, since I do not want the user interface thread to hang when it evaluates the LINQ expression on request in the user interface thread (this is in Silverlight BTW). Therefore, I would like to report on progress. UX is basically:
- User drags item to workspace
- Then, the engine starts a background thread to determine (many) the possibilities of connecting to all other elements of the workspace.
- , , "" ( , , LINQ).
- (), , (, , , , ).
( )