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

ToObservableLongRunning<TSource>

sealed class ToObservableLongRunning<TSource> : Producer<TSource, _<TSource>>
using System.Collections.Generic; using System.Reactive.Concurrency; using System.Reactive.Disposables; using System.Runtime.CompilerServices; namespace System.Reactive.Linq.ObservableImpl { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1, 1, 1 })] internal sealed class ToObservableLongRunning<[System.Runtime.CompilerServices.Nullable(2)] TSource> : Producer<TSource, ToObservableLongRunning<TSource>._> { [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] internal sealed class _ : IdentitySink<TSource> { public _(IObserver<TSource> observer) : base(observer) { } public void Run(IEnumerable<TSource> source, ISchedulerLongRunning scheduler) { IEnumerator<TSource> enumerator; try { enumerator = source.GetEnumerator(); } catch (Exception error) { ForwardOnError(error); return; } SetUpstream(scheduler.ScheduleLongRunning<(_, IEnumerator<TSource>)>((this, enumerator), (Action<(_, IEnumerator<TSource>), ICancelable>)delegate((_ this, IEnumerator<TSource> e) tuple, ICancelable cancelable) { tuple.this.Loop(tuple.e, cancelable); })); } private void Loop(IEnumerator<TSource> enumerator, ICancelable cancel) { while (!cancel.IsDisposed) { bool flag = false; Exception ex = null; TSource value = default(TSource); try { flag = enumerator.MoveNext(); if (flag) value = enumerator.Current; } catch (Exception ex2) { ex = ex2; } if (ex != null) { ForwardOnError(ex); break; } if (!flag) { ForwardOnCompleted(); break; } ForwardOnNext(value); } enumerator.Dispose(); Dispose(); } } private readonly IEnumerable<TSource> _source; private readonly ISchedulerLongRunning _scheduler; public ToObservableLongRunning(IEnumerable<TSource> source, ISchedulerLongRunning scheduler) { _source = source; _scheduler = scheduler; } [return: System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0 })] protected override _ CreateSink(IObserver<TSource> observer) { return new _(observer); } protected override void Run([System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0 })] _ sink) { sink.Run(_source, _scheduler); } } }