Editar

Partilhar via


DataflowBlock.Choose Method

Definition

Overloads

Choose<T1,T2,T3>(ISourceBlock<T1>, Action<T1>, ISourceBlock<T2>, Action<T2>, ISourceBlock<T3>, Action<T3>)

Monitors three dataflow sources, invoking the provided handler for whichever source makes data available first.

Choose<T1,T2,T3>(ISourceBlock<T1>, Action<T1>, ISourceBlock<T2>, Action<T2>, ISourceBlock<T3>, Action<T3>, DataflowBlockOptions)

Monitors three dataflow sources, invoking the provided handler for whichever source makes data available first.

Choose<T1,T2>(ISourceBlock<T1>, Action<T1>, ISourceBlock<T2>, Action<T2>)

Monitors two dataflow sources, invoking the provided handler for whichever source makes data available first.

Choose<T1,T2>(ISourceBlock<T1>, Action<T1>, ISourceBlock<T2>, Action<T2>, DataflowBlockOptions)

Monitors two dataflow sources, invoking the provided handler for whichever source makes data available first.

Choose<T1,T2,T3>(ISourceBlock<T1>, Action<T1>, ISourceBlock<T2>, Action<T2>, ISourceBlock<T3>, Action<T3>)

Source:
DataflowBlock.cs
Source:
DataflowBlock.cs
Source:
DataflowBlock.cs
Source:
DataflowBlock.cs

Monitors three dataflow sources, invoking the provided handler for whichever source makes data available first.

public:
generic <typename T1, typename T2, typename T3>
 static System::Threading::Tasks::Task<int> ^ Choose(System::Threading::Tasks::Dataflow::ISourceBlock<T1> ^ source1, Action<T1> ^ action1, System::Threading::Tasks::Dataflow::ISourceBlock<T2> ^ source2, Action<T2> ^ action2, System::Threading::Tasks::Dataflow::ISourceBlock<T3> ^ source3, Action<T3> ^ action3);
public static System.Threading.Tasks.Task<int> Choose<T1,T2,T3> (System.Threading.Tasks.Dataflow.ISourceBlock<T1> source1, Action<T1> action1, System.Threading.Tasks.Dataflow.ISourceBlock<T2> source2, Action<T2> action2, System.Threading.Tasks.Dataflow.ISourceBlock<T3> source3, Action<T3> action3);
static member Choose : System.Threading.Tasks.Dataflow.ISourceBlock<'T1> * Action<'T1> * System.Threading.Tasks.Dataflow.ISourceBlock<'T2> * Action<'T2> * System.Threading.Tasks.Dataflow.ISourceBlock<'T3> * Action<'T3> -> System.Threading.Tasks.Task<int>
Public Function Choose(Of T1, T2, T3) (source1 As ISourceBlock(Of T1), action1 As Action(Of T1), source2 As ISourceBlock(Of T2), action2 As Action(Of T2), source3 As ISourceBlock(Of T3), action3 As Action(Of T3)) As Task(Of Integer)

Type Parameters

T1

Specifies type of data contained in the first source.

T2

Specifies type of data contained in the second source.

T3

Specifies type of data contained in the third source.

Parameters

source1
ISourceBlock<T1>

The first source.

action1
Action<T1>

The handler to execute on data from the first source.

source2
ISourceBlock<T2>

The second source.

action2
Action<T2>

The handler to execute on data from the second source.

source3
ISourceBlock<T3>

The third source.

action3
Action<T3>

The handler to execute on data from the third source.

Returns

A Task<TResult> that represents the asynchronous choice. If all sources are completed prior to the choice completing, the resulting task will be canceled. When one of the sources has data available and successfully propagates it to the choice, the resulting task will complete when the handler completes; if the handler throws an exception, the task will end in the Faulted state and will contain the unhandled exception. Otherwise, the task will end with its Result set to the 0-based index of the source.

This method will only consume an element from one of the data sources, never more than one.

Exceptions

The source1 is null.

-or-

The action1 is null.

-or-

The source2 is null.

-or-

The action2 is null.

-or-

The source3 is null.

-or-

The action3 is null.

Applies to

Choose<T1,T2,T3>(ISourceBlock<T1>, Action<T1>, ISourceBlock<T2>, Action<T2>, ISourceBlock<T3>, Action<T3>, DataflowBlockOptions)

Source:
DataflowBlock.cs
Source:
DataflowBlock.cs
Source:
DataflowBlock.cs
Source:
DataflowBlock.cs

Monitors three dataflow sources, invoking the provided handler for whichever source makes data available first.

public:
generic <typename T1, typename T2, typename T3>
 static System::Threading::Tasks::Task<int> ^ Choose(System::Threading::Tasks::Dataflow::ISourceBlock<T1> ^ source1, Action<T1> ^ action1, System::Threading::Tasks::Dataflow::ISourceBlock<T2> ^ source2, Action<T2> ^ action2, System::Threading::Tasks::Dataflow::ISourceBlock<T3> ^ source3, Action<T3> ^ action3, System::Threading::Tasks::Dataflow::DataflowBlockOptions ^ dataflowBlockOptions);
public static System.Threading.Tasks.Task<int> Choose<T1,T2,T3> (System.Threading.Tasks.Dataflow.ISourceBlock<T1> source1, Action<T1> action1, System.Threading.Tasks.Dataflow.ISourceBlock<T2> source2, Action<T2> action2, System.Threading.Tasks.Dataflow.ISourceBlock<T3> source3, Action<T3> action3, System.Threading.Tasks.Dataflow.DataflowBlockOptions dataflowBlockOptions);
static member Choose : System.Threading.Tasks.Dataflow.ISourceBlock<'T1> * Action<'T1> * System.Threading.Tasks.Dataflow.ISourceBlock<'T2> * Action<'T2> * System.Threading.Tasks.Dataflow.ISourceBlock<'T3> * Action<'T3> * System.Threading.Tasks.Dataflow.DataflowBlockOptions -> System.Threading.Tasks.Task<int>
Public Function Choose(Of T1, T2, T3) (source1 As ISourceBlock(Of T1), action1 As Action(Of T1), source2 As ISourceBlock(Of T2), action2 As Action(Of T2), source3 As ISourceBlock(Of T3), action3 As Action(Of T3), dataflowBlockOptions As DataflowBlockOptions) As Task(Of Integer)

Type Parameters

T1

Specifies type of data contained in the first source.

T2

Specifies type of data contained in the second source.

T3

Specifies type of data contained in the third source.

Parameters

source1
ISourceBlock<T1>

The first source.

action1
Action<T1>

The handler to execute on data from the first source.

source2
ISourceBlock<T2>

The second source.

action2
Action<T2>

The handler to execute on data from the second source.

source3
ISourceBlock<T3>

The third source.

action3
Action<T3>

The handler to execute on data from the third source.

dataflowBlockOptions
DataflowBlockOptions

The options with which to configure this choice.

Returns

A Task<TResult> that represents the asynchronous choice. If all sources are completed prior to the choice completing, or if the CancellationToken provided as part of dataflowBlockOptions is canceled prior to the choice completing, the resulting task will be canceled. When one of the sources has data available and successfully propagates it to the choice, the resulting task will complete when the handler completes; if the handler throws an exception, the task will end in the Faulted state and will contain the unhandled exception. Otherwise, the task will end with its Result set to the 0-based index of the source.

This method will only consume an element from one of the data sources, never more than one. If cancellation is requested after an element has been received, the cancellation request will be ignored, and the relevant handler will be allowed to execute.

Exceptions

The source1 is null.

-or-

The action1 is null.

-or-

The source2 is null.

-or-

The action2 is null.

-or-

The source3 is null.

-or-

The action3 is null.

-or-

The dataflowBlockOptions is null.

Applies to

Choose<T1,T2>(ISourceBlock<T1>, Action<T1>, ISourceBlock<T2>, Action<T2>)

Source:
DataflowBlock.cs
Source:
DataflowBlock.cs
Source:
DataflowBlock.cs
Source:
DataflowBlock.cs

Monitors two dataflow sources, invoking the provided handler for whichever source makes data available first.

public:
generic <typename T1, typename T2>
 static System::Threading::Tasks::Task<int> ^ Choose(System::Threading::Tasks::Dataflow::ISourceBlock<T1> ^ source1, Action<T1> ^ action1, System::Threading::Tasks::Dataflow::ISourceBlock<T2> ^ source2, Action<T2> ^ action2);
public static System.Threading.Tasks.Task<int> Choose<T1,T2> (System.Threading.Tasks.Dataflow.ISourceBlock<T1> source1, Action<T1> action1, System.Threading.Tasks.Dataflow.ISourceBlock<T2> source2, Action<T2> action2);
static member Choose : System.Threading.Tasks.Dataflow.ISourceBlock<'T1> * Action<'T1> * System.Threading.Tasks.Dataflow.ISourceBlock<'T2> * Action<'T2> -> System.Threading.Tasks.Task<int>
Public Function Choose(Of T1, T2) (source1 As ISourceBlock(Of T1), action1 As Action(Of T1), source2 As ISourceBlock(Of T2), action2 As Action(Of T2)) As Task(Of Integer)

Type Parameters

T1

Specifies type of data contained in the first source.

T2

Specifies type of data contained in the second source.

Parameters

source1
ISourceBlock<T1>

The first source.

action1
Action<T1>

The handler to execute on data from the first source.

source2
ISourceBlock<T2>

The second source.

action2
Action<T2>

The handler to execute on data from the second source.

Returns

A Task<TResult> that represents the asynchronous choice. If both sources are completed prior to the choice completing, the resulting task will be canceled. When one of the sources has data available and successfully propagates it to the choice, the resulting task will complete when the handler completes; if the handler throws an exception, the task will end in the Faulted state and will contain the unhandled exception. Otherwise, the task will end with its Result set to either 0 or 1 to represent the first or second source, respectively.

This method will only consume an element from one of the two data sources, never both.

Exceptions

The source1 is null.

-or-

The action1 is null.

-or-

The source2 is null.

-or-

The action2 is null.

Applies to

Choose<T1,T2>(ISourceBlock<T1>, Action<T1>, ISourceBlock<T2>, Action<T2>, DataflowBlockOptions)

Source:
DataflowBlock.cs
Source:
DataflowBlock.cs
Source:
DataflowBlock.cs
Source:
DataflowBlock.cs

Monitors two dataflow sources, invoking the provided handler for whichever source makes data available first.

public:
generic <typename T1, typename T2>
 static System::Threading::Tasks::Task<int> ^ Choose(System::Threading::Tasks::Dataflow::ISourceBlock<T1> ^ source1, Action<T1> ^ action1, System::Threading::Tasks::Dataflow::ISourceBlock<T2> ^ source2, Action<T2> ^ action2, System::Threading::Tasks::Dataflow::DataflowBlockOptions ^ dataflowBlockOptions);
public static System.Threading.Tasks.Task<int> Choose<T1,T2> (System.Threading.Tasks.Dataflow.ISourceBlock<T1> source1, Action<T1> action1, System.Threading.Tasks.Dataflow.ISourceBlock<T2> source2, Action<T2> action2, System.Threading.Tasks.Dataflow.DataflowBlockOptions dataflowBlockOptions);
static member Choose : System.Threading.Tasks.Dataflow.ISourceBlock<'T1> * Action<'T1> * System.Threading.Tasks.Dataflow.ISourceBlock<'T2> * Action<'T2> * System.Threading.Tasks.Dataflow.DataflowBlockOptions -> System.Threading.Tasks.Task<int>
Public Function Choose(Of T1, T2) (source1 As ISourceBlock(Of T1), action1 As Action(Of T1), source2 As ISourceBlock(Of T2), action2 As Action(Of T2), dataflowBlockOptions As DataflowBlockOptions) As Task(Of Integer)

Type Parameters

T1

Specifies type of data contained in the first source.

T2

Specifies type of data contained in the second source.

Parameters

source1
ISourceBlock<T1>

The first source.

action1
Action<T1>

The handler to execute on data from the first source.

source2
ISourceBlock<T2>

The second source.

action2
Action<T2>

The handler to execute on data from the second source.

dataflowBlockOptions
DataflowBlockOptions

The options with which to configure this choice.

Returns

A Task<TResult> that represents the asynchronous choice. If both sources are completed prior to the choice completing, or if the CancellationToken provided as part of dataflowBlockOptions is canceled prior to the choice completing, the resulting task will be canceled. When one of the sources has data available and successfully propagates it to the choice, the resulting task will complete when the handler completes; if the handler throws an exception, the task will end in the Faulted state and will contain the unhandled exception. Otherwise, the task will end with its Result set to either 0 or 1 to represent the first or second source, respectively.

Exceptions

The source1 is null.

-or-

The action1 is null.

-or-

The source2 is null.

-or-

The action2 is null.

-or-

The dataflowBlockOptions is null.

Applies to