Table of Contents

Class TimeBatchBlock<T>

Namespace
DotnetKit.DataflowBuilder.CustomBlocks
Assembly
DotnetKit.DataflowBuilder.dll

A custom propagator block that groups incoming items into batches of up to batchSize items, or flushes earlier if a specified timeout duration has elapsed since the first buffered item.

public class TimeBatchBlock<T> : BasePropagatorBlock<T, T[]>, IPropagatorBlock<T, T[]>, ITargetBlock<T>, ISourceBlock<T[]>, IDataflowBlock

Type Parameters

T

The type of incoming data items.

Inheritance
TimeBatchBlock<T>
Implements
Inherited Members

Constructors

TimeBatchBlock(int, TimeSpan, CancellationToken)

Initializes a new instance of the TimeBatchBlock<T> class.

public TimeBatchBlock(int batchSize, TimeSpan timeout, CancellationToken cancellationToken = default)

Parameters

batchSize int

The maximum number of items per batch.

timeout TimeSpan

The maximum time to wait before emitting a partial batch.

cancellationToken CancellationToken

A token to monitor for cancellation requests.

Exceptions

ArgumentOutOfRangeException

Thrown if batchSize is less than 1 or timeout is negative.

Properties

Source

Gets the egress source block.

public override ISourceBlock<T[]> Source { get; }

Property Value

ISourceBlock<T[]>

Target

Gets the entry target block.

public override ITargetBlock<T> Target { get; }

Property Value

ITargetBlock<T>

Methods

Complete()

Signals the target block that no more data will be provided, and propagates completion to the source block.

public override void Complete()

Fault(Exception)

Causes the encapsulated dataflow block to complete in a faulted state with the specified exception.

public override void Fault(Exception exception)

Parameters

exception Exception

The exception that caused the fault.