Creates a task grouping items into batches of a specified size.
Items are processed sequentially and order is preserved both across batches and within each batch.
If size is 0 or negative, collects all items into a single batch. The final batch may contain fewer items than the specified size.
The type of items in the stream
The maximum number of items per batch (0 or negative for unbounded)
A task that groups items into batches
0 Copy
0
When size is 0 or negative, all stream items are accumulated in memory before yielding a single batch. For large or infinite streams, this may cause memory issues. Use a positive size for bounded memory consumption.
Creates a task grouping items into batches of a specified size.
Items are processed sequentially and order is preserved both across batches and within each batch.
If size is 0 or negative, collects all items into a single batch. The final batch may contain fewer items than the specified size.