Class DataflowPipeline<TSource1, TSource2>
- Namespace
- DotnetKit.DataflowBuilder
- Assembly
- DotnetKit.DataflowBuilder.dll
Implements an executable multi-source dataflow pipeline that receives items from two distinct sources, joining them internally for downstream pipeline processing.
public class DataflowPipeline<TSource1, TSource2> : IPipeline<TSource1, TSource2>, IPipeline<Tuple<TSource1, TSource2>>
Type Parameters
TSource1The type of elements accepted by the first source.
TSource2The type of elements accepted by the second source.
- Inheritance
-
DataflowPipeline<TSource1, TSource2>
- Implements
-
IPipeline<TSource1, TSource2>
- Inherited Members
- Extension Methods
Constructors
DataflowPipeline(JoinBlock<TSource1, TSource2>, IDataflowBlock)
Initializes a new instance of the DataflowPipeline<TSource1, TSource2> class.
public DataflowPipeline(JoinBlock<TSource1, TSource2> sourceBlock, IDataflowBlock destinationBlock)
Parameters
sourceBlockJoinBlock<TSource1, TSource2>The join block joining input streams from both sources.
destinationBlockIDataflowBlockThe final block in the pipeline chain whose completion signals overall termination.
Exceptions
- ArgumentNullException
Thrown if
sourceBlockordestinationBlockis null.
Methods
CompleteAsync()
Signals completion to both source targets and waits asynchronously for all pipeline stages to complete.
public Task CompleteAsync()
Returns
- Task
A task representing the overall completion of the pipeline.
Send1Async(TSource1, CancellationToken)
Asynchronously sends a data item to the first source input.
public Task Send1Async(TSource1 dataItem, CancellationToken cancellationToken = default)
Parameters
dataItemTSource1The item to send to the first source.
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Returns
- Task
A task that completes when the item is accepted.
Send2Async(TSource2, CancellationToken)
Asynchronously sends a data item to the second source input.
public Task Send2Async(TSource2 dataItem, CancellationToken cancellationToken = default)
Parameters
dataItemTSource2The item to send to the second source.
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Returns
- Task
A task that completes when the item is accepted.
SendAsync(Tuple<TSource1, TSource2>, CancellationToken)
Sending combined tuples directly is not supported in a multi-source pipeline; use Send1Async(TSource1, CancellationToken) and Send2Async(TSource2, CancellationToken) instead.
public Task SendAsync(Tuple<TSource1, TSource2> dataItem, CancellationToken cancellationToken = default)
Parameters
dataItemTuple<TSource1, TSource2>The tuple payload.
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Returns
Exceptions
- NotSupportedException
Always thrown because inputs must be posted via Send1Async(TSource1, CancellationToken) and Send2Async(TSource2, CancellationToken).