Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
201 lines (186 sloc) 12.4 KB
<Type Name="ParallelOptions" FullName="System.Threading.Tasks.ParallelOptions">
<TypeSignature Language="C#" Value="public class ParallelOptions" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit ParallelOptions extends System.Object" />
<TypeSignature Language="DocId" Value="T:System.Threading.Tasks.ParallelOptions" />
<TypeSignature Language="VB.NET" Value="Public Class ParallelOptions" />
<TypeSignature Language="C++ CLI" Value="public ref class ParallelOptions" />
<TypeSignature Language="F#" Value="type ParallelOptions = class" />
<AssemblyInfo>
<AssemblyName>System.Threading.Tasks.Parallel</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>Stores options that configure the operation of methods on the <see cref="T:System.Threading.Tasks.Parallel" /> class.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
By default, methods on the <xref:System.Threading.Tasks.Parallel> class attempt to use all available processors, are non-cancelable, and target the default <xref:System.Threading.Tasks.TaskScheduler> (<xref:System.Threading.Tasks.TaskScheduler.Default?displayProperty=nameWithType>). <xref:System.Threading.Tasks.ParallelOptions> enables overriding these defaults.
]]></format>
</remarks>
<threadsafe>The constructor is thread-safe and may be used by multiple threads concurrently to construct multiple instances. None of the other public members are thread-safe.</threadsafe>
<related type="Article" href="~/docs/standard/parallel-programming/data-parallelism-task-parallel-library.md">Data Parallelism (Task Parallel Library)</related>
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public ParallelOptions ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Threading.Tasks.ParallelOptions.#ctor" />
<MemberSignature Language="VB.NET" Value="Public Sub New ()" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; ParallelOptions();" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Threading.Tasks.Parallel</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters />
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Threading.Tasks.ParallelOptions" /> class.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This constructor initializes the instance with default values. <xref:System.Threading.Tasks.ParallelOptions.MaxDegreeOfParallelism%2A> is initialized to -1, signifying that there is no upper bound set on how much parallelism should be employed. <xref:System.Threading.Tasks.ParallelOptions.CancellationToken%2A> is initialized to a non-cancelable token, and <xref:System.Threading.Tasks.ParallelOptions.TaskScheduler%2A> is initialized to the default scheduler (TaskScheduler.Default).
All of these defaults may be overwritten using the property set accessors on the instance.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="CancellationToken">
<MemberSignature Language="C#" Value="public System.Threading.CancellationToken CancellationToken { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance valuetype System.Threading.CancellationToken CancellationToken" />
<MemberSignature Language="DocId" Value="P:System.Threading.Tasks.ParallelOptions.CancellationToken" />
<MemberSignature Language="VB.NET" Value="Public Property CancellationToken As CancellationToken" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property System::Threading::CancellationToken CancellationToken { System::Threading::CancellationToken get(); void set(System::Threading::CancellationToken value); };" />
<MemberSignature Language="F#" Value="member this.CancellationToken : System.Threading.CancellationToken with get, set" Usage="System.Threading.Tasks.ParallelOptions.CancellationToken" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Threading.Tasks.Parallel</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Threading.CancellationToken</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the <see cref="T:System.Threading.CancellationToken" /> associated with this <see cref="T:System.Threading.Tasks.ParallelOptions" /> instance.</summary>
<value>The token that is associated with this instance.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Providing a <xref:System.Threading.CancellationToken> to a <xref:System.Threading.Tasks.Parallel> method enables the operation to be exited early. Code external to the operation may cancel the token, and if the operation observes the token being set, it may exit early by throwing an <xref:System.OperationCanceledException>.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="MaxDegreeOfParallelism">
<MemberSignature Language="C#" Value="public int MaxDegreeOfParallelism { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance int32 MaxDegreeOfParallelism" />
<MemberSignature Language="DocId" Value="P:System.Threading.Tasks.ParallelOptions.MaxDegreeOfParallelism" />
<MemberSignature Language="VB.NET" Value="Public Property MaxDegreeOfParallelism As Integer" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property int MaxDegreeOfParallelism { int get(); void set(int value); };" />
<MemberSignature Language="F#" Value="member this.MaxDegreeOfParallelism : int with get, set" Usage="System.Threading.Tasks.ParallelOptions.MaxDegreeOfParallelism" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Threading.Tasks.Parallel</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the maximum number of concurrent tasks enabled by this <see cref="T:System.Threading.Tasks.ParallelOptions" /> instance.</summary>
<value>An integer that represents the maximum degree of parallelism.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Threading.Tasks.ParallelOptions.MaxDegreeOfParallelism%2A> property affects the number of concurrent operations run by <xref:System.Threading.Tasks.Parallel> method calls that are passed this <xref:System.Threading.Tasks.ParallelOptions> instance. A positive property value limits the number of concurrent operations to the set value. If it is -1, there is no limit on the number of concurrently running operations.
By default, <xref:System.Threading.Tasks.Parallel.For%2A> and <xref:System.Threading.Tasks.Parallel.ForEach%2A> will utilize however many threads the underlying scheduler provides, so changing <xref:System.Threading.Tasks.ParallelOptions.MaxDegreeOfParallelism%2A> from the default only limits how many concurrent tasks will be used.
Generally, you do not need to modify this setting. However, you may choose to set it explicitly in advanced usage scenarios such as these:
- When you know that a particular algorithm you're using won't scale beyond a certain number of cores. You can set the property to avoid wasting cycles on additional cores.
- When you're running multiple algorithms concurrently and want to manually define how much of the system each algorithm can utilize. You can set a <xref:System.Threading.Tasks.ParallelOptions.MaxDegreeOfParallelism%2A> value for each.
- When the thread pool's heuristics is unable to determine the right number of threads to use and could end up injecting too many threads. For example, in long-running loop body iterations, the thread pool might not be able to tell the difference between reasonable progress or livelock or deadlock, and might not be able to reclaim threads that were added to improve performance. In this case, you can set the property to ensure that you don't use more than a reasonable number of threads.
]]></format>
</remarks>
<exception cref="T:System.ArgumentOutOfRangeException">The property is being set to zero or to a value that is less than -1.</exception>
</Docs>
</Member>
<Member MemberName="TaskScheduler">
<MemberSignature Language="C#" Value="public System.Threading.Tasks.TaskScheduler TaskScheduler { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Threading.Tasks.TaskScheduler TaskScheduler" />
<MemberSignature Language="DocId" Value="P:System.Threading.Tasks.ParallelOptions.TaskScheduler" />
<MemberSignature Language="VB.NET" Value="Public Property TaskScheduler As TaskScheduler" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property System::Threading::Tasks::TaskScheduler ^ TaskScheduler { System::Threading::Tasks::TaskScheduler ^ get(); void set(System::Threading::Tasks::TaskScheduler ^ value); };" />
<MemberSignature Language="F#" Value="member this.TaskScheduler : System.Threading.Tasks.TaskScheduler with get, set" Usage="System.Threading.Tasks.ParallelOptions.TaskScheduler" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Threading.Tasks.Parallel</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Threading.Tasks.TaskScheduler</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the <see cref="T:System.Threading.Tasks.TaskScheduler" /> associated with this <see cref="T:System.Threading.Tasks.ParallelOptions" /> instance. Setting this property to null indicates that the current scheduler should be used.</summary>
<value>The task scheduler that is associated with this instance.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
</Members>
</Type>
You can’t perform that action at this time.