Class Gate
Represents an operator that allows a single element from the first sequence to pass through every time a second sequence emits a notification.
When the gate is in the open state, a single element is allowed to pass through from the source sequence. After this first element is emitted, the gate closes and all subsequent elements are dropped from the result sequence. The gate reopens when the second sequence emits a notification.
It is possible to specify how long the gate stays open by using the DueTime property. If no value is specified, the gate stays open indefinitely until an element arrives. In this case, the gate starts immediately in the open state.
If a maximum due time is specified, no elements from the source sequence arriving after the due time elapses will be allowed through and the gate may close again without emitting any new elements. In this case, the gate starts in the closed state, and only opens when the second sequence emits a notification.
Warning
If the second sequence emits notifications before the gate is closed, the gate will remain open. If there is a maximum specified due time, the timer will be reset upon arrival of the new notification. Even if there are multiple opening notifications, only a single element can make it through the gate.
[Combinator]
public class Gate
- Inheritance
-
Gate
- Inherited Members
Properties
DueTime
Gets or sets a value specifying the maximum time the gate stays open.
public TimeSpan? DueTime { get; set; }
Property Value
Remarks
If no value is specified, the gate stays open indefinitely until an element arrives. If a maximum due time is specified, however, then if an element from the first sequence arrives after this interval elapses, that element will not be allowed through and will be dropped from the result sequence.
Methods
Process<TSource, TGateOpening>(IObservable<TSource>, IObservable<TGateOpening>)
Allows a single element from an observable sequence to pass through every time a second sequence emits a notification.
public IObservable<TSource> Process<TSource, TGateOpening>(IObservable<TSource> source, IObservable<TGateOpening> gateOpenings)
Parameters
source
IObservable<TSource>The observable sequence to filter.
gateOpenings
IObservable<TGateOpening>The sequence of gate opening events.
Returns
- IObservable<TSource>
The filtered observable sequence. Every time the
gateOpenings
sequence produces a notification, the next element from thesource
sequence will be allowed through.
Type Parameters
TSource
The type of the elements in the
source
sequence.TGateOpening
The type of the elements in the
gateOpenings
sequence.