. NET parallel programming practices (1: Basic Introduction to. NET parallel computing and parallel loop use mode)

Source: Internet
Author: User

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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.