,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.Window(IObservable, Func>) method¶
Defined in
Type: Observable
Namespace: System.Reactive.Linq
Assembly: System.Reactive.dll
Applies to
netstandard2.0
Overloads¶
- 1.
public static IObservable<IObservable<TSource>> Window<TSource, TWindowClosing>(this IObservable<TSource> source, Func<IObservable<TWindowClosing>> windowClosingSelector) - 2.
public static IObservable<IObservable<TSource>> Window<TSource, TWindowOpening, TWindowClosing>(this IObservable<TSource> source, IObservable<TWindowOpening> windowOpenings, Func<TWindowOpening, IObservable<TWindowClosing>> windowClosingSelector) - 3.
public static IObservable<IObservable<TSource>> Window<TSource, TWindowBoundary>(this IObservable<TSource> source, IObservable<TWindowBoundary> windowBoundaries) - 4.
public static IObservable<IObservable<TSource>> Window<TSource>(this IObservable<TSource> source, int count) - 5.
public static IObservable<IObservable<TSource>> Window<TSource>(this IObservable<TSource> source, int count, int skip) - 6.
public static IObservable<IObservable<TSource>> Window<TSource>(this IObservable<TSource> source, TimeSpan timeSpan) - 7.
public static IObservable<IObservable<TSource>> Window<TSource>(this IObservable<TSource> source, TimeSpan timeSpan, IScheduler scheduler) - 8.
public static IObservable<IObservable<TSource>> Window<TSource>(this IObservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift) - 9.
public static IObservable<IObservable<TSource>> Window<TSource>(this IObservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift, IScheduler scheduler) - 10.
public static IObservable<IObservable<TSource>> Window<TSource>(this IObservable<TSource> source, TimeSpan timeSpan, int count) - 11.
public static IObservable<IObservable<TSource>> Window<TSource>(this IObservable<TSource> source, TimeSpan timeSpan, int count, IScheduler scheduler)
1. Overload¶
public static IObservable<IObservable<TSource>> Window<TSource, TWindowClosing>(this IObservable<TSource> source, Func<IObservable<TWindowClosing>> windowClosingSelector)
Summary: Projects each element of an observable sequence into consecutive non-overlapping windows.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence, and in the windows in the result sequence. |
TWindowClosing | The type of the elements in the sequences indicating window closing events. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to produce windows over. |
windowClosingSelector | Func | A function invoked to define the boundaries of the produced windows. A new window is started when the previous one is closed. |
Returns: IObservable
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or windowClosingSelector is null. |
2. Overload¶
public static IObservable<IObservable<TSource>> Window<TSource, TWindowOpening, TWindowClosing>(this IObservable<TSource> source, IObservable<TWindowOpening> windowOpenings, Func<TWindowOpening, IObservable<TWindowClosing>> windowClosingSelector)
Summary: Projects each element of an observable sequence into zero or more windows.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence, and in the windows in the result sequence. |
TWindowOpening | The type of the elements in the sequence indicating window opening events, also passed to the closing selector to obtain a sequence of window closing events. |
TWindowClosing | The type of the elements in the sequences indicating window closing events. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to produce windows over. |
windowOpenings | IObservable | Observable sequence whose elements denote the creation of new windows. |
windowClosingSelector | Func | A function invoked to define the closing of each produced window. |
Returns: IObservable
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or windowOpenings or windowClosingSelector is null. |
3. Overload¶
public static IObservable<IObservable<TSource>> Window<TSource, TWindowBoundary>(this IObservable<TSource> source, IObservable<TWindowBoundary> windowBoundaries)
Summary: Projects each element of an observable sequence into consecutive non-overlapping windows.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence, and in the windows in the result sequence. |
TWindowBoundary | The type of the elements in the sequences indicating window boundary events. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to produce windows over. |
windowBoundaries | IObservable | Sequence of window boundary markers. The current window is closed and a new window is opened upon receiving a boundary marker. |
Returns: IObservable
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or windowBoundaries is null. |
4. Overload¶
public static IObservable<IObservable<TSource>> Window<TSource>(this IObservable<TSource> source, int count)
Summary: Projects each element of an observable sequence into consecutive non-overlapping windows 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 windows in the result sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to produce windows over. |
count | int | Length of each window. |
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<IObservable<TSource>> Window<TSource>(this IObservable<TSource> source, int count, int skip)
Summary: Projects each element of an observable sequence into zero or more windows 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 windows in the result sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to produce windows over. |
count | int | Length of each window. |
skip | int | Number of elements to skip between creation of consecutive windows. |
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<IObservable<TSource>> Window<TSource>(this IObservable<TSource> source, TimeSpan timeSpan)
Summary: Projects each element of an observable sequence into consecutive non-overlapping windows which are produced based on timing information.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence, and in the windows in the result sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to produce windows over. |
timeSpan | TimeSpan | Length of each window. |
Returns: IObservable
Remarks
Specifying a TimeSpan.Zero value for timeSpan is not recommended but supported, causing the scheduler to create windows as fast as it can.
Because all source sequence elements end up in one of the windows, some windows 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 window and to create a new window 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<IObservable<TSource>> Window<TSource>(this IObservable<TSource> source, TimeSpan timeSpan, IScheduler scheduler)
Summary: Projects each element of an observable sequence into consecutive non-overlapping windows 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 windows in the result sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to produce windows over. |
timeSpan | TimeSpan | Length of each window. |
scheduler | [IScheduler](# | Scheduler to run windowing timers on. |
Returns: IObservable
Remarks
Specifying a TimeSpan.Zero value for timeSpan is not recommended but supported, causing the scheduler to create windows as fast as it can.
Because all source sequence elements end up in one of the windows, some windows 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 window and to create a new window 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<IObservable<TSource>> Window<TSource>(this IObservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift)
Summary: Projects each element of an observable sequence into zero or more windows which are produced based on timing information.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence, and in the windows in the result sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to produce windows over. |
timeSpan | TimeSpan | Length of each window. |
timeShift | TimeSpan | Interval between creation of consecutive windows. |
Returns: IObservable
Remarks
Specifying a TimeSpan.Zero value for timeSpan is not recommended but supported, causing the scheduler to create windows with minimum duration
length. However, some windows 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 window 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 windows as fast as it can.
However, this doesn't mean all windows 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 window 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<IObservable<TSource>> Window<TSource>(this IObservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift, IScheduler scheduler)
Summary: Projects each element of an observable sequence into zero or more windows 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 windows in the result sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to produce windows over. |
timeSpan | TimeSpan | Length of each window. |
timeShift | TimeSpan | Interval between creation of consecutive windows. |
scheduler | [IScheduler](# | Scheduler to run windowing timers on. |
Returns: IObservable
Remarks
Specifying a TimeSpan.Zero value for timeSpan is not recommended but supported, causing the scheduler to create windows with minimum duration
length. However, some windows 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 window 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 windows as fast as it can.
However, this doesn't mean all windows 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 window 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<IObservable<TSource>> Window<TSource>(this IObservable<TSource> source, TimeSpan timeSpan, int count)
Summary: Projects each element of an observable sequence into a window that is completed 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 windows in the result sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to produce windows 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 windows as fast as it can.
Because all source sequence elements end up in one of the windows, some windows 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 window and to create a new window 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<IObservable<TSource>> Window<TSource>(this IObservable<TSource> source, TimeSpan timeSpan, int count, IScheduler scheduler)
Summary: Projects each element of an observable sequence into a window that is completed 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 windows in the result sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to produce windows over. |
timeSpan | TimeSpan | Maximum time length of a window. |
count | int | Maximum element count of a window. |
scheduler | [IScheduler](# | Scheduler to run windowing timers on. |
Returns: IObservable
Remarks
Specifying a TimeSpan.Zero value for timeSpan is not recommended but supported, causing the scheduler to create windows as fast as it can.
Because all source sequence elements end up in one of the windows, some windows 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 window and to create a new window 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. |