1. Introduction
2. Basic Introduction to. NET parallel computing
3. Parallel loop mode
List <Order> orders = List <Order> (I =; I <; I ++ orders. add (Order () {Oid = Guid. newGuid (). toString (), OName = + Console. writeLine (Stopwatch watch = orders. forEach (order => order. isSubmit = count = (I =; I <; I ++ count ++ Console. writeLine (Stopwatch watch = Parallel. forEach (orders, order => order. isSubmit = count = (I =; I <; I ++ count ++}View Code
The small loop parallel mode will not improve the performance, but will reduce the performance.); This is to make the simulation scenario more realistic;
3.1] parallel For Loop
Parallel. For (, orders. Count, index => });View Code
3.2] parallel ForEach Loop
Parallel. ForEach (orders, order => order. IsSubmit = count = (I =; I <; I ++ count ++ });View Code
3.3] parallel LINQ (PLINQ)
ParallelQuery <TSource>: ParallelQuery, IEnumerable <TSource> IEnumerator <TSource>}View Code
ParallelEnumerable {}View Code
Items = item orders. AsParallel () item. OName. Contains () item;View Code