,System.TimeSpan)} ,System.TimeSpan,System.Reactive.Concurrency.IScheduler)} ,System.TimeSpan,System.IObservable{--0})} ,System.TimeSpan,System.IObservable{--0},System.Reactive.Concurrency.IScheduler)} ,System.DateTimeOffset)} ,System.DateTimeOffset,System.Reactive.Concurrency.IScheduler)} ,System.DateTimeOffset,System.IObservable{--0})} ,System.DateTimeOffset,System.IObservable{--0},System.Reactive.Concurrency.IScheduler)} ,System.Func{--0,System.IObservable{--1}})} ,System.Func{--0,System.IObservable{--1}},System.IObservable{--0})} ,System.IObservable{--1},System.Func{--0,System.IObservable{--1}})} ,System.IObservable{--1},System.Func{--0,System.IObservable{--1}},System.IObservable{--0})}
Observable.Timeout(IObservable, TimeSpan) method¶
Defined in
Type: Observable
Namespace: System.Reactive.Linq
Assembly: System.Reactive.dll
Applies to
netstandard2.0
Overloads¶
- 1.
public static IObservable<TSource> Timeout<TSource>(this IObservable<TSource> source, TimeSpan dueTime) - 2.
public static IObservable<TSource> Timeout<TSource>(this IObservable<TSource> source, TimeSpan dueTime, IScheduler scheduler) - 3.
public static IObservable<TSource> Timeout<TSource>(this IObservable<TSource> source, TimeSpan dueTime, IObservable<TSource> other) - 4.
public static IObservable<TSource> Timeout<TSource>(this IObservable<TSource> source, TimeSpan dueTime, IObservable<TSource> other, IScheduler scheduler) - 5.
public static IObservable<TSource> Timeout<TSource>(this IObservable<TSource> source, DateTimeOffset dueTime) - 6.
public static IObservable<TSource> Timeout<TSource>(this IObservable<TSource> source, DateTimeOffset dueTime, IScheduler scheduler) - 7.
public static IObservable<TSource> Timeout<TSource>(this IObservable<TSource> source, DateTimeOffset dueTime, IObservable<TSource> other) - 8.
public static IObservable<TSource> Timeout<TSource>(this IObservable<TSource> source, DateTimeOffset dueTime, IObservable<TSource> other, IScheduler scheduler) - 9.
public static IObservable<TSource> Timeout<TSource, TTimeout>(this IObservable<TSource> source, Func<TSource, IObservable<TTimeout>> timeoutDurationSelector) - 10.
public static IObservable<TSource> Timeout<TSource, TTimeout>(this IObservable<TSource> source, Func<TSource, IObservable<TTimeout>> timeoutDurationSelector, IObservable<TSource> other) - 11.
public static IObservable<TSource> Timeout<TSource, TTimeout>(this IObservable<TSource> source, IObservable<TTimeout> firstTimeout, Func<TSource, IObservable<TTimeout>> timeoutDurationSelector) - 12.
public static IObservable<TSource> Timeout<TSource, TTimeout>(this IObservable<TSource> source, IObservable<TTimeout> firstTimeout, Func<TSource, IObservable<TTimeout>> timeoutDurationSelector, IObservable<TSource> other)
1. Overload¶
public static IObservable<TSource> Timeout<TSource>(this IObservable<TSource> source, TimeSpan dueTime)
Summary: Applies a timeout policy for each element in the observable sequence. If the next element isn't received within the specified timeout duration starting from its predecessor, a TimeoutException is propagated to the observer.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to perform a timeout for. |
dueTime | TimeSpan | Maximum duration between values before a timeout occurs. |
Returns: IObservable
Remarks
In case you only want to timeout on the first element, consider using the Amb operator applied to the source sequence and a delayed Throw sequence. Alternatively, the general-purpose overload of Timeout, Timeout can be used.
Specifying a TimeSpan.Zero value for dueTime is not recommended but supported, causing timeout timers to be scheduled that are due
immediately. However, this doesn't guarantee a timeout will occur, even for the first element. This is a side-effect of the asynchrony introduced by the
scheduler, where the action to propagate a timeout may not execute immediately, despite the TimeSpan.Zero due time. In such cases, the next element may
arrive before the scheduler gets a chance to run the timeout action.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source is null. |
| System.ArgumentOutOfRangeException | dueTime is less than TimeSpan.Zero. |
| System.TimeoutException | (Asynchronous) If no element is produced within dueTime from the previous element. |
2. Overload¶
public static IObservable<TSource> Timeout<TSource>(this IObservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
Summary: Applies a timeout policy for each element in the observable sequence, using the specified scheduler to run timeout timers. If the next element isn't received within the specified timeout duration starting from its predecessor, a TimeoutException is propagated to the observer.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to perform a timeout for. |
dueTime | TimeSpan | Maximum duration between values before a timeout occurs. |
scheduler | [IScheduler](# | Scheduler to run the timeout timers on. |
Returns: IObservable
Remarks
In case you only want to timeout on the first element, consider using the Amb operator applied to the source sequence and a delayed Throw sequence. Alternatively, the general-purpose overload of Timeout, Timeout can be used.
Specifying a TimeSpan.Zero value for dueTime is not recommended but supported, causing timeout timers to be scheduled that are due
immediately. However, this doesn't guarantee a timeout will occur, even for the first element. This is a side-effect of the asynchrony introduced by the
scheduler, where the action to propagate a timeout may not execute immediately, despite the TimeSpan.Zero due time. In such cases, the next element may
arrive before the scheduler gets a chance to run the timeout action.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or scheduler is null. |
| System.ArgumentOutOfRangeException | dueTime is less than TimeSpan.Zero. |
| System.TimeoutException | (Asynchronous) If no element is produced within dueTime from the previous element. |
3. Overload¶
public static IObservable<TSource> Timeout<TSource>(this IObservable<TSource> source, TimeSpan dueTime, IObservable<TSource> other)
Summary: Applies a timeout policy for each element in the observable sequence. If the next element isn't received within the specified timeout duration starting from its predecessor, the other observable sequence is used to produce future messages from that point on.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence and the other sequence used upon a timeout. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to perform a timeout for. |
dueTime | TimeSpan | Maximum duration between values before a timeout occurs. |
other | IObservable | Sequence to return in case of a timeout. |
Returns: IObservable
Remarks
In case you only want to timeout on the first element, consider using the Amb operator applied to the source sequence and a delayed Throw sequence. Alternatively, the general-purpose overload of Timeout, Timeout can be used.
Specifying a TimeSpan.Zero value for dueTime is not recommended but supported, causing timeout timers to be scheduled that are due
immediately. However, this doesn't guarantee a timeout will occur, even for the first element. This is a side-effect of the asynchrony introduced by the
scheduler, where the action to propagate a timeout may not execute immediately, despite the TimeSpan.Zero due time. In such cases, the next element may
arrive before the scheduler gets a chance to run the timeout action.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or other is null. |
| System.ArgumentOutOfRangeException | dueTime is less than TimeSpan.Zero. |
4. Overload¶
public static IObservable<TSource> Timeout<TSource>(this IObservable<TSource> source, TimeSpan dueTime, IObservable<TSource> other, IScheduler scheduler)
Summary: Applies a timeout policy for each element in the observable sequence, using the specified scheduler to run timeout timers. If the next element isn't received within the specified timeout duration starting from its predecessor, the other observable sequence is used to produce future messages from that point on.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence and the other sequence used upon a timeout. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to perform a timeout for. |
dueTime | TimeSpan | Maximum duration between values before a timeout occurs. |
other | IObservable | Sequence to return in case of a timeout. |
scheduler | [IScheduler](# | Scheduler to run the timeout timers on. |
Returns: IObservable
Remarks
In case you only want to timeout on the first element, consider using the Amb operator applied to the source sequence and a delayed Throw sequence. Alternatively, the general-purpose overload of Timeout, Timeout can be used.
Specifying a TimeSpan.Zero value for dueTime is not recommended but supported, causing timeout timers to be scheduled that are due
immediately. However, this doesn't guarantee a timeout will occur, even for the first element. This is a side-effect of the asynchrony introduced by the
scheduler, where the action to propagate a timeout may not execute immediately, despite the TimeSpan.Zero due time. In such cases, the next element may
arrive before the scheduler gets a chance to run the timeout action.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or other or scheduler is null. |
| System.ArgumentOutOfRangeException | dueTime is less than TimeSpan.Zero. |
5. Overload¶
public static IObservable<TSource> Timeout<TSource>(this IObservable<TSource> source, DateTimeOffset dueTime)
Summary: Applies a timeout policy to the observable sequence based on an absolute time. If the sequence doesn't terminate before the specified absolute due time, a TimeoutException is propagated to the observer.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to perform a timeout for. |
dueTime | DateTimeOffset | Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately. |
Returns: IObservable
Remarks
In case you only want to timeout on the first element, consider using the Amb operator applied to the source sequence and a delayed Throw sequence. Alternatively, the general-purpose overload of Timeout, Timeout can be used.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source is null. |
| System.TimeoutException | (Asynchronous) If the sequence hasn't terminated before dueTime. |
6. Overload¶
public static IObservable<TSource> Timeout<TSource>(this IObservable<TSource> source, DateTimeOffset dueTime, IScheduler scheduler)
Summary: Applies a timeout policy to the observable sequence based on an absolute time, using the specified scheduler to run timeout timers. If the sequence doesn't terminate before the specified absolute due time, a TimeoutException is propagated to the observer.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to perform a timeout for. |
dueTime | DateTimeOffset | Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately. |
scheduler | [IScheduler](# | Scheduler to run the timeout timers on. |
Returns: IObservable
Remarks
In case you only want to timeout on the first element, consider using the Amb operator applied to the source sequence and a delayed Throw sequence. Alternatively, the general-purpose overload of Timeout, Timeout can be used.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or scheduler is null. |
| System.TimeoutException | (Asynchronous) If the sequence hasn't terminated before dueTime. |
7. Overload¶
public static IObservable<TSource> Timeout<TSource>(this IObservable<TSource> source, DateTimeOffset dueTime, IObservable<TSource> other)
Summary: Applies a timeout policy to the observable sequence based on an absolute time. If the sequence doesn't terminate before the specified absolute due time, the other observable sequence is used to produce future messages from that point on.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence and the other sequence used upon a timeout. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to perform a timeout for. |
dueTime | DateTimeOffset | Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately. |
other | IObservable | Sequence to return in case of a timeout. |
Returns: IObservable
Remarks
In case you only want to timeout on the first element, consider using the Amb operator applied to the source sequence and a delayed Throw sequence. Alternatively, the general-purpose overload of Timeout, Timeout can be used.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or other is null. |
8. Overload¶
public static IObservable<TSource> Timeout<TSource>(this IObservable<TSource> source, DateTimeOffset dueTime, IObservable<TSource> other, IScheduler scheduler)
Summary: Applies a timeout policy to the observable sequence based on an absolute time, using the specified scheduler to run timeout timers. If the sequence doesn't terminate before the specified absolute due time, the other observable sequence is used to produce future messages from that point on.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence and the other sequence used upon a timeout. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to perform a timeout for. |
dueTime | DateTimeOffset | Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately. |
other | IObservable | Sequence to return in case of a timeout. |
scheduler | [IScheduler](# | Scheduler to run the timeout timers on. |
Returns: IObservable
Remarks
In case you only want to timeout on the first element, consider using the Amb operator applied to the source sequence and a delayed Throw sequence. Alternatively, the general-purpose overload of Timeout, Timeout can be used.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or other or scheduler is null. |
9. Overload¶
public static IObservable<TSource> Timeout<TSource, TTimeout>(this IObservable<TSource> source, Func<TSource, IObservable<TTimeout>> timeoutDurationSelector)
Summary: Applies a timeout policy to the observable sequence based on a timeout duration computed for each element. If the next element isn't received within the computed duration starting from its predecessor, a TimeoutException is propagated to the observer.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
TTimeout | The type of the elements in the timeout sequences used to indicate the timeout duration for each element in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to perform a timeout for. |
timeoutDurationSelector | Func | Selector to retrieve an observable sequence that represents the timeout between the current element and the next element. |
Returns: IObservable
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or timeoutDurationSelector is null. |
10. Overload¶
public static IObservable<TSource> Timeout<TSource, TTimeout>(this IObservable<TSource> source, Func<TSource, IObservable<TTimeout>> timeoutDurationSelector, IObservable<TSource> other)
Summary: Applies a timeout policy to the observable sequence based on a timeout duration computed for each element. If the next element isn't received within the computed duration starting from its predecessor, the other observable sequence is used to produce future messages from that point on.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence and the other sequence used upon a timeout. |
TTimeout | The type of the elements in the timeout sequences used to indicate the timeout duration for each element in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to perform a timeout for. |
timeoutDurationSelector | Func | Selector to retrieve an observable sequence that represents the timeout between the current element and the next element. |
other | IObservable | Sequence to return in case of a timeout. |
Returns: IObservable
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or timeoutDurationSelector or other is null. |
11. Overload¶
public static IObservable<TSource> Timeout<TSource, TTimeout>(this IObservable<TSource> source, IObservable<TTimeout> firstTimeout, Func<TSource, IObservable<TTimeout>> timeoutDurationSelector)
Summary: Applies a timeout policy to the observable sequence based on an initial timeout duration for the first element, and a timeout duration computed for each subsequent element. If the next element isn't received within the computed duration starting from its predecessor, a TimeoutException is propagated to the observer.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
TTimeout | The type of the elements in the timeout sequences used to indicate the timeout duration for each element in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to perform a timeout for. |
firstTimeout | IObservable | Observable sequence that represents the timeout for the first element. |
timeoutDurationSelector | Func | Selector to retrieve an observable sequence that represents the timeout between the current element and the next element. |
Returns: IObservable
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or firstTimeout or timeoutDurationSelector is null. |
12. Overload¶
public static IObservable<TSource> Timeout<TSource, TTimeout>(this IObservable<TSource> source, IObservable<TTimeout> firstTimeout, Func<TSource, IObservable<TTimeout>> timeoutDurationSelector, IObservable<TSource> other)
Summary: Applies a timeout policy to the observable sequence based on an initial timeout duration for the first element, and a timeout duration computed for each subsequent element. If the next element isn't received within the computed duration starting from its predecessor, the other observable sequence is used to produce future messages from that point on.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence and the other sequence used upon a timeout. |
TTimeout | The type of the elements in the timeout sequences used to indicate the timeout duration for each element in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to perform a timeout for. |
firstTimeout | IObservable | Observable sequence that represents the timeout for the first element. |
timeoutDurationSelector | Func | Selector to retrieve an observable sequence that represents the timeout between the current element and the next element. |
other | IObservable | Sequence to return in case of a timeout. |
Returns: IObservable
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or firstTimeout or timeoutDurationSelector or other is null. |