System.Threading.Parallel.ParallelEnvironment Class

public sealed class ParallelEnvironment

Base Types

Object
  ParallelEnvironment

Assembly

mscorlib

Library

Parallel

Summary

Provides the current settings for, and information about, the parallel-loop execution environment.

See Also

System.Threading.Parallel Namespace

Members

ParallelEnvironment Properties

ParallelEnvironment.MaxThreads Property
ParallelEnvironment.RecommendedMaxThreads Property


ParallelEnvironment.MaxThreads Property

public static int MaxThreads { get; set; }

Summary

Default upper bound on the number of threads employed by a parallel loop.

Property Value

A Int32 that limits the number of worker threads employed by parallel loop constructs that do not explicitly specify an upper bound on the number of threads. The bound includes the thread that calls System.Threading.Parallel.ParallelLoop<T>.BeginRun, and hence MaxThreads must be positive.

Description

Setting System.Threading.Parallel.ParallelEnvironment.MaxThreads to 1 causes deterministic sequential execution of all parallel loop constructs that do not explicitly specify an upper bound on the number of threads. This is useful for debugging of code. Ordinarily, System.Threading.Parallel.ParallelEnvironment.MaxThreads should not be set in production code because it affects parallel loops everywhere in a program.

The initial value is System.Threading.Parallel.ParallelEnvironment.RecommendedMaxThreads.

See Also

System.Threading.Parallel.ParallelEnvironment Class, System.Threading.Parallel Namespace

ParallelEnvironment.RecommendedMaxThreads Property

public static int RecommendedMaxThreads { get; }

Summary

Recommended value for System.Threading.Parallel.ParallelEnvironment.MaxThreads

Property Value

A Int32 that is the initial value for System.Threading.Parallel.ParallelEnvironment.MaxThreads.

Description

Values between 1x and 2x the number of physical threads on the platform are recommended.

See Also

System.Threading.Parallel.ParallelEnvironment Class, System.Threading.Parallel Namespace