BatchBlock<T> Class

Definition

Provides a dataflow block that batches inputs into arrays.

public sealed class BatchBlock<T> : System.Threading.Tasks.Dataflow.IPropagatorBlock<T,T[]>, System.Threading.Tasks.Dataflow.IReceivableSourceBlock<T[]>, System.Threading.Tasks.Dataflow.ISourceBlock<T[]>, System.Threading.Tasks.Dataflow.ITargetBlock<T>
Type Parameters
T

Specifies the type of data put into batches.

Inheritance
BatchBlock<T>
Implements

Inherited Members

System.Object

Remarks

Note

The TPL Dataflow Library (System.Threading.Tasks.Dataflow namespace) is not distributed with the .NET Framework 4.5. To install the System.Threading.Tasks.Dataflow namespace, open your project in Visual Studio 2012, choose Manage NuGet Packages from the Project menu, and search online for the Microsoft.Tpl.Dataflow package.

Constructors

BatchBlock<T>(Int32)

Initializes a new BatchBlock<T> with the specified batch size.

BatchBlock<T>(Int32, GroupingDataflowBlockOptions)

Initializes a new BatchBlock<T> with the specified batch size, declining option, and block options.

Properties

BatchSize

Gets the size of the batches generated by this BatchBlock<T>.

Completion

Gets a Task that represents the asynchronous operation and completion of the dataflow block.

OutputCount

Gets the number of output items available to be received from this block.

Methods

Complete()

Signals to the IDataflowBlock that it should not accept nor produce any more messages nor consume any more postponed messages.

LinkTo(ITargetBlock<T[]>, DataflowLinkOptions)

Links the ISourceBlock<TOutput> to the specified ITargetBlock<TInput> .

ToString()

Returns a string that represents the formatted name of this IDataflowBlock instance.

TriggerBatch()

Triggers the BatchBlock<T> to initiate a batching operation even if the number of currently queued or postponed items is less than the BatchSize.

TryReceive(Predicate<T[]>, T[])

Attempts to synchronously receive an available output item from the IReceivableSourceBlock<TOutput>.

TryReceiveAll(IList<T[]>)

Attempts to synchronously receive all available items from the IReceivableSourceBlock<TOutput>.

Explicit Interface Implementations

IDataflowBlock.Fault(Exception)

Causes the IDataflowBlock to complete in a Faulted state.

ISourceBlock<T[]>.ConsumeMessage(DataflowMessageHeader, ITargetBlock<T[]>, Boolean)

Called by a linked ITargetBlock<TInput> to accept and consume a DataflowMessageHeader previously offered by this ISourceBlock<TOutput> .

ISourceBlock<T[]>.ReleaseReservation(DataflowMessageHeader, ITargetBlock<T[]>)

Called by a linked ITargetBlock<TInput> to release a previously reserved DataflowMessageHeader by this ISourceBlock<TOutput>.

ISourceBlock<T[]>.ReserveMessage(DataflowMessageHeader, ITargetBlock<T[]>)

Called by a linked ITargetBlock<TInput> to reserve a previously offered DataflowMessageHeader by this ISourceBlock<TOutput>.

ITargetBlock<T>.OfferMessage(DataflowMessageHeader, T, ISourceBlock<T>, Boolean)

Offers a message to the ITargetBlock<TInput>, giving the target the opportunity to consume or postpone the message.

Extension Methods

AsObservable<TOutput>(ISourceBlock<TOutput>)
AsObserver<TInput>(ITargetBlock<TInput>)
LinkTo<TOutput>(ISourceBlock<TOutput>, ITargetBlock<TOutput>)
LinkTo<TOutput>(ISourceBlock<TOutput>, ITargetBlock<TOutput>, Predicate<TOutput>)
LinkTo<TOutput>(ISourceBlock<TOutput>, ITargetBlock<TOutput>, DataflowLinkOptions, Predicate<TOutput>)
OutputAvailableAsync<TOutput>(ISourceBlock<TOutput>)
OutputAvailableAsync<TOutput>(ISourceBlock<TOutput>, CancellationToken)
Post<TInput>(ITargetBlock<TInput>, TInput)
Receive<TOutput>(ISourceBlock<TOutput>)
Receive<TOutput>(ISourceBlock<TOutput>, CancellationToken)
Receive<TOutput>(ISourceBlock<TOutput>, TimeSpan)
Receive<TOutput>(ISourceBlock<TOutput>, TimeSpan, CancellationToken)
ReceiveAsync<TOutput>(ISourceBlock<TOutput>)
ReceiveAsync<TOutput>(ISourceBlock<TOutput>, CancellationToken)
ReceiveAsync<TOutput>(ISourceBlock<TOutput>, TimeSpan)
ReceiveAsync<TOutput>(ISourceBlock<TOutput>, TimeSpan, CancellationToken)
SendAsync<TInput>(ITargetBlock<TInput>, TInput)
SendAsync<TInput>(ITargetBlock<TInput>, TInput, CancellationToken)
TryReceive<TOutput>(IReceivableSourceBlock<TOutput>, TOutput)