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

ScheduledItem<TAbsolute>

public abstract class ScheduledItem<TAbsolute> : IScheduledItem<TAbsolute>, IComparable<ScheduledItem<TAbsolute>>, IDisposable where TAbsolute : IComparable<TAbsolute>
Abstract base class for scheduled work items.
using System.Collections.Generic; using System.Reactive.Disposables; using System.Runtime.CompilerServices; namespace System.Reactive.Concurrency { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] public abstract class ScheduledItem<[System.Runtime.CompilerServices.Nullable(0)] TAbsolute> : IScheduledItem<TAbsolute>, IComparable<ScheduledItem<TAbsolute>>, IDisposable where TAbsolute : IComparable<TAbsolute> { private SingleAssignmentDisposableValue _disposable; private readonly IComparer<TAbsolute> _comparer; public TAbsolute DueTime { get; } public bool IsCanceled => _disposable.IsDisposed; protected ScheduledItem(TAbsolute dueTime, IComparer<TAbsolute> comparer) { DueTime = dueTime; if (comparer == null) throw new ArgumentNullException("comparer"); _comparer = comparer; } public void Invoke() { if (!_disposable.IsDisposed) _disposable.Disposable = InvokeCore(); } protected abstract IDisposable InvokeCore(); public int CompareTo([System.Runtime.CompilerServices.Nullable(new byte[] { 2, 1 })] ScheduledItem<TAbsolute> other) { if ((object)other == null) return 1; return _comparer.Compare(DueTime, other.DueTime); } public static bool operator <(ScheduledItem<TAbsolute> left, ScheduledItem<TAbsolute> right) { return Comparer<ScheduledItem<TAbsolute>>.Default.Compare(left, right) < 0; } public static bool operator <=(ScheduledItem<TAbsolute> left, ScheduledItem<TAbsolute> right) { return Comparer<ScheduledItem<TAbsolute>>.Default.Compare(left, right) <= 0; } public static bool operator >(ScheduledItem<TAbsolute> left, ScheduledItem<TAbsolute> right) { return Comparer<ScheduledItem<TAbsolute>>.Default.Compare(left, right) > 0; } public static bool operator >=(ScheduledItem<TAbsolute> left, ScheduledItem<TAbsolute> right) { return Comparer<ScheduledItem<TAbsolute>>.Default.Compare(left, right) >= 0; } public static bool operator ==([System.Runtime.CompilerServices.Nullable(new byte[] { 2, 1 })] ScheduledItem<TAbsolute> left, [System.Runtime.CompilerServices.Nullable(new byte[] { 2, 1 })] ScheduledItem<TAbsolute> right) { return (object)left == right; } public static bool operator !=([System.Runtime.CompilerServices.Nullable(new byte[] { 2, 1 })] ScheduledItem<TAbsolute> left, [System.Runtime.CompilerServices.Nullable(new byte[] { 2, 1 })] ScheduledItem<TAbsolute> right) { return !(left == right); } [System.Runtime.CompilerServices.NullableContext(2)] public override bool Equals(object obj) { return this == obj; } public override int GetHashCode() { return base.GetHashCode(); } public void Cancel() { _disposable.Dispose(); } void IDisposable.Dispose() { Cancel(); } } }