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
TThe type of incoming data items.
- Inheritance
-
BasePropagatorBlock<T, T[]>TimeBatchBlock<T>
- Implements
-
IPropagatorBlock<T, T[]>ITargetBlock<T>ISourceBlock<T[]>
- 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
batchSizeintThe maximum number of items per batch.
timeoutTimeSpanThe maximum time to wait before emitting a partial batch.
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Exceptions
- ArgumentOutOfRangeException
Thrown if
batchSizeis less than 1 ortimeoutis 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
exceptionExceptionThe exception that caused the fault.