Information Technology Reference
In-Depth Information
testing element: 11
testing element: 12
testing element: 13
testing element: 14
testing element: 15
testing element: 16
testing element: 17
testing element: 18
testing element: 19
testing element: 20
projecting an element: 20
called MoveNext
Delivered 20 at 1:46:08 PM
testing element: 21
testing element: 22
testing element: 23
testing element: 24
testing element: 25
testing element: 26
testing element: 27
testing element: 28
testing element: 29
testing element: 30
projecting an element: 30
The query does not begin to execute until the first call to MoveNext() on
the enumerator. The first call to MoveNext() executes the query on enough
elements to retrieve the first element on the result sequence (which hap-
pens to be one element for this query). The next call to MoveNext()
processes elements in the input sequence until the next item in the output
sequence has been produced. Using LINQ to Objects, each call to
MoveNext() executes the query on as many elements are necessary to pro-
duce the next output element.
The rules change once you change the query to be a parallel query:
var answers = from n in ParallelEnumerable .Range(0, 300)
where n.SomeTest()
select n.SomeProjection();
The output from this query will look very different. Here's a sample from
one run (it will change somewhat for each run):
Search WWH ::




Custom Search