,System.Func{System.IObservable{--1}})} ,System.IObservable{--1},System.Func{--1,System.IObservable{--2}})} ,System.IObservable{--1})} ,System.Int32)} ,System.Int32,System.Int32)} ,System.TimeSpan)} ,System.TimeSpan,System.Reactive.Concurrency.IScheduler)} ,System.TimeSpan,System.TimeSpan)} ,System.TimeSpan,System.TimeSpan,System.Reactive.Concurrency.IScheduler)} ,System.TimeSpan,System.Int32)} ,System.TimeSpan,System.Int32,System.Reactive.Concurrency.IScheduler)}
Observable.Buffer(IObservable, Func>) method¶
Defined in
Type: Observable
Namespace: System.Reactive.Linq
Assembly: System.Reactive.dll
Applies to
netstandard2.0
Overloads¶
- 1.
public static IObservable<IList<TSource>> Buffer<TSource, TBufferClosing>(this IObservable<TSource> source, Func<IObservable<TBufferClosing>> bufferClosingSelector) - 2.
public static IObservable<IList<TSource>> Buffer<TSource, TBufferOpening, TBufferClosing>(this IObservable<TSource> source, IObservable<TBufferOpening> bufferOpenings, Func<TBufferOpening, IObservable<TBufferClosing>> bufferClosingSelector) - 3.
public static IObservable<IList<TSource>> Buffer<TSource, TBufferBoundary>(this IObservable<TSource> source, IObservable<TBufferBoundary> bufferBoundaries) - 4.
public static IObservable<IList<TSource>> Buffer<TSource>(this IObservable<TSource> source, int count) - 5.
public static IObservable<IList<TSource>> Buffer<TSource>(this IObservable<TSource> source, int count, int skip) - 6.
public static IObservable<IList<TSource>> Buffer<TSource>(this IObservable<TSource> source, TimeSpan timeSpan) - 7.
public static IObservable<IList<TSource>> Buffer<TSource>(this IObservable<TSource> source, TimeSpan timeSpan, IScheduler scheduler) - 8.
public static IObservable<IList<TSource>> Buffer<TSource>(this IObservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift) - 9.
public static IObservable<IList<TSource>> Buffer<TSource>(this IObservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift, IScheduler scheduler) - 10.
public static IObservable<IList<TSource>> Buffer<TSource>(this IObservable<TSource> source, TimeSpan timeSpan, int count) - 11.
public static IObservable<IList<TSource>> Buffer<TSource>(this IObservable<TSource> source, TimeSpan timeSpan, int count, IScheduler scheduler)
1. Overload¶
public static IObservable<IList<TSource>> Buffer<TSource, TBufferClosing>(this IObservable<TSource> source, Func<IObservable<TBufferClosing>> bufferClosingSelector)
Summary: Projects each element of an observable sequence into consecutive non-overlapping buffers.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence, and in the lists in the result sequence. |
TBufferClosing | The type of the elements in the sequences indicating buffer closing events. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to produce buffers over. |
bufferClosingSelector | Func | A function invoked to define the boundaries of the produced buffers. A new buffer is started when the previous one is closed. |
Returns: IObservable
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or bufferClosingSelector is null. |
2. Overload¶
public static IObservable<IList<TSource>> Buffer<TSource, TBufferOpening, TBufferClosing>(this IObservable<TSource> source, IObservable<TBufferOpening> bufferOpenings, Func<TBufferOpening, IObservable<TBufferClosing>> bufferClosingSelector)
Summary: Projects each element of an observable sequence into zero or more buffers.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence, and in the lists in the result sequence. |
TBufferOpening | The type of the elements in the sequence indicating buffer opening events, also passed to the closing selector to obtain a sequence of buffer closing events. |
TBufferClosing | The type of the elements in the sequences indicating buffer closing events. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to produce buffers over. |
bufferOpenings | IObservable | Observable sequence whose elements denote the creation of new buffers. |
bufferClosingSelector | Func | A function invoked to define the closing of each produced buffer. |
Returns: IObservable
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or bufferOpenings or bufferClosingSelector is null. |
3. Overload¶
public static IObservable<IList<TSource>> Buffer<TSource, TBufferBoundary>(this IObservable<TSource> source, IObservable<TBufferBoundary> bufferBoundaries)
Summary: Projects each element of an observable sequence into consecutive non-overlapping buffers.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence, and in the lists in the result sequence. |
TBufferBoundary | The type of the elements in the sequences indicating buffer boundary events. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to produce buffers over. |
bufferBoundaries | IObservable | Sequence of buffer boundary markers. The current buffer is closed and a new buffer is opened upon receiving a boundary marker. |
Returns: IObservable
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or bufferBoundaries is null. |
4. Overload¶
public static IObservable<IList<TSource>> Buffer<TSource>(this IObservable<TSource> source, int count)
Summary: Projects each element of an observable sequence into consecutive non-overlapping buffers which are produced based on element count information.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence, and in the lists in the result sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to produce buffers over. |
count | int | Length of each buffer. |
Returns: IObservable
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source is null. |
| System.ArgumentOutOfRangeException | count is less than or equal to zero. |
5. Overload¶
public static IObservable<IList<TSource>> Buffer<TSource>(this IObservable<TSource> source, int count, int skip)
Summary: Projects each element of an observable sequence into zero or more buffers which are produced based on element count information.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence, and in the lists in the result sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to produce buffers over. |
count | int | Length of each buffer. |
skip | int | Number of elements to skip between creation of consecutive buffers. |
Returns: IObservable
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source is null. |
| System.ArgumentOutOfRangeException | count or skip is less than or equal to zero. |
6. Overload¶
public static IObservable<IList<TSource>> Buffer<TSource>(this IObservable<TSource> source, TimeSpan timeSpan)
Summary: Projects each element of an observable sequence into consecutive non-overlapping buffers which are produced based on timing information.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence, and in the lists in the result sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to produce buffers over. |
timeSpan | TimeSpan | Length of each buffer. |
Returns: IObservable
Remarks
Specifying a TimeSpan.Zero value for timeSpan is not recommended but supported, causing the scheduler to create buffers as fast as it can.
Because all source sequence elements end up in one of the buffers, some buffers won't have a zero time span. This is a side-effect of the asynchrony introduced
by the scheduler, where the action to close the current buffer and to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source is null. |
| System.ArgumentOutOfRangeException | timeSpan is less than TimeSpan.Zero. |
7. Overload¶
public static IObservable<IList<TSource>> Buffer<TSource>(this IObservable<TSource> source, TimeSpan timeSpan, IScheduler scheduler)
Summary: Projects each element of an observable sequence into consecutive non-overlapping buffers which are produced based on timing information, using the specified scheduler to run timers.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence, and in the lists in the result sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to produce buffers over. |
timeSpan | TimeSpan | Length of each buffer. |
scheduler | [IScheduler](# | Scheduler to run buffering timers on. |
Returns: IObservable
Remarks
Specifying a TimeSpan.Zero value for timeSpan is not recommended but supported, causing the scheduler to create buffers as fast as it can.
Because all source sequence elements end up in one of the buffers, some buffers won't have a zero time span. This is a side-effect of the asynchrony introduced
by the scheduler, where the action to close the current buffer and to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or scheduler is null. |
| System.ArgumentOutOfRangeException | timeSpan is less than TimeSpan.Zero. |
8. Overload¶
public static IObservable<IList<TSource>> Buffer<TSource>(this IObservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift)
Summary: Projects each element of an observable sequence into zero or more buffers which are produced based on timing information.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence, and in the lists in the result sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to produce buffers over. |
timeSpan | TimeSpan | Length of each buffer. |
timeShift | TimeSpan | Interval between creation of consecutive buffers. |
Returns: IObservable
Remarks
Specifying a TimeSpan.Zero value for timeSpan is not recommended but supported, causing the scheduler to create buffers with minimum duration
length. However, some buffers won't have a zero time span. This is a side-effect of the asynchrony introduced by the scheduler, where the action to close the
current buffer may not execute immediately, despite the TimeSpan.Zero due time.
Specifying a TimeSpan.Zero value for timeShift is not recommended but supported, causing the scheduler to create buffers as fast as it can.
However, this doesn't mean all buffers will start at the beginning of the source sequence. This is a side-effect of the asynchrony introduced by the scheduler,
where the action to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source is null. |
| System.ArgumentOutOfRangeException | timeSpan or timeSpan is less than TimeSpan.Zero. |
9. Overload¶
public static IObservable<IList<TSource>> Buffer<TSource>(this IObservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift, IScheduler scheduler)
Summary: Projects each element of an observable sequence into zero or more buffers which are produced based on timing information, using the specified scheduler to run timers.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence, and in the lists in the result sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to produce buffers over. |
timeSpan | TimeSpan | Length of each buffer. |
timeShift | TimeSpan | Interval between creation of consecutive buffers. |
scheduler | [IScheduler](# | Scheduler to run buffering timers on. |
Returns: IObservable
Remarks
Specifying a TimeSpan.Zero value for timeSpan is not recommended but supported, causing the scheduler to create buffers with minimum duration
length. However, some buffers won't have a zero time span. This is a side-effect of the asynchrony introduced by the scheduler, where the action to close the
current buffer may not execute immediately, despite the TimeSpan.Zero due time.
Specifying a TimeSpan.Zero value for timeShift is not recommended but supported, causing the scheduler to create buffers as fast as it can.
However, this doesn't mean all buffers will start at the beginning of the source sequence. This is a side-effect of the asynchrony introduced by the scheduler,
where the action to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or scheduler is null. |
| System.ArgumentOutOfRangeException | timeSpan or timeSpan is less than TimeSpan.Zero. |
10. Overload¶
public static IObservable<IList<TSource>> Buffer<TSource>(this IObservable<TSource> source, TimeSpan timeSpan, int count)
Summary: Projects each element of an observable sequence into a buffer that's sent out when either it's full or a given amount of time has elapsed. A useful real-world analogy of this overload is the behavior of a ferry leaving the dock when all seats are taken, or at the scheduled time of departure, whichever event occurs first.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence, and in the lists in the result sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to produce buffers over. |
timeSpan | TimeSpan | Maximum time length of a window. |
count | int | Maximum element count of a window. |
Returns: IObservable
Remarks
Specifying a TimeSpan.Zero value for timeSpan is not recommended but supported, causing the scheduler to create buffers as fast as it can.
Because all source sequence elements end up in one of the buffers, some buffers won't have a zero time span. This is a side-effect of the asynchrony introduced
by the scheduler, where the action to close the current buffer and to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source is null. |
| System.ArgumentOutOfRangeException | timeSpan is less than TimeSpan.Zero. -or- count is less than or equal to zero. |
11. Overload¶
public static IObservable<IList<TSource>> Buffer<TSource>(this IObservable<TSource> source, TimeSpan timeSpan, int count, IScheduler scheduler)
Summary: Projects each element of an observable sequence into a buffer that's sent out when either it's full or a given amount of time has elapsed, using the specified scheduler to run timers. A useful real-world analogy of this overload is the behavior of a ferry leaving the dock when all seats are taken, or at the scheduled time of departure, whichever event occurs first.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence, and in the lists in the result sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to produce buffers over. |
timeSpan | TimeSpan | Maximum time length of a buffer. |
count | int | Maximum element count of a buffer. |
scheduler | [IScheduler](# | Scheduler to run buffering timers on. |
Returns: IObservable
Remarks
Specifying a TimeSpan.Zero value for timeSpan is not recommended but supported, causing the scheduler to create buffers as fast as it can.
Because all source sequence elements end up in one of the buffers, some buffers won't have a zero time span. This is a side-effect of the asynchrony introduced
by the scheduler, where the action to close the current buffer and to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or scheduler is null. |
| System.ArgumentOutOfRangeException | timeSpan is less than TimeSpan.Zero. -or- count is less than or equal to zero. |