<PackageReference Include="System.Reactive" Version="6.0.0" />

TimeInterval<TSource>

sealed class TimeInterval<TSource> : Producer<TimeInterval<TSource>, _<TSource>>
using System.Reactive.Concurrency; using System.Runtime.CompilerServices; namespace System.Reactive.Linq.ObservableImpl { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 0, 1, 1, 1 })] internal sealed class TimeInterval<[System.Runtime.CompilerServices.Nullable(2)] TSource> : Producer<System.Reactive.TimeInterval<TSource>, TimeInterval<TSource>._> { [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1, 0, 1 })] internal sealed class _ : Sink<TSource, System.Reactive.TimeInterval<TSource>> { [System.Runtime.CompilerServices.Nullable(2)] private IStopwatch _watch; private TimeSpan _last; public _([System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0, 1 })] IObserver<System.Reactive.TimeInterval<TSource>> observer) : base(observer) { } public void Run(TimeInterval<TSource> parent) { _watch = parent._scheduler.StartStopwatch(); _last = TimeSpan.Zero; SetUpstream(parent._source.Subscribe(this)); } public override void OnNext(TSource value) { TimeSpan elapsed = _watch.Elapsed; TimeSpan interval = elapsed.Subtract(_last); _last = elapsed; ForwardOnNext(new System.Reactive.TimeInterval<TSource>(value, interval)); } } private readonly IObservable<TSource> _source; private readonly IScheduler _scheduler; public TimeInterval(IObservable<TSource> source, IScheduler scheduler) { _source = source; _scheduler = scheduler; } [return: System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0 })] protected override _ CreateSink([System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0, 1 })] IObserver<System.Reactive.TimeInterval<TSource>> observer) { return new _(observer); } protected override void Run([System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0 })] _ sink) { sink.Run(this); } } }