HistoricalScheduler
Provides a virtual time scheduler that uses  DateTimeOffset for absolute time and  TimeSpan for relative time.
            
                using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace System.Reactive.Concurrency
{
    [System.Runtime.CompilerServices.NullableContext(1)]
    [System.Runtime.CompilerServices.Nullable(0)]
    [DebuggerDisplay("\\{ Clock = {Clock} Now = {Now.ToString(\"O\")} \\}")]
    public class HistoricalScheduler : HistoricalSchedulerBase
    {
        private readonly SchedulerQueue<DateTimeOffset> _queue = new SchedulerQueue<DateTimeOffset>();
        public HistoricalScheduler()
        {
        }
        public HistoricalScheduler(DateTimeOffset initialClock)
            : base(initialClock)
        {
        }
        public HistoricalScheduler(DateTimeOffset initialClock, IComparer<DateTimeOffset> comparer)
            : base(initialClock, comparer)
        {
        }
        [System.Runtime.CompilerServices.NullableContext(2)]
        protected override IScheduledItem<DateTimeOffset> GetNext()
        {
            while (_queue.Count > 0) {
                ScheduledItem<DateTimeOffset> scheduledItem = _queue.Peek();
                if (!scheduledItem.IsCanceled)
                    return scheduledItem;
                _queue.Dequeue();
            }
            return null;
        }
        public override IDisposable ScheduleAbsolute<[System.Runtime.CompilerServices.Nullable(2)] TState>(TState state, DateTimeOffset dueTime, Func<IScheduler, TState, IDisposable> action)
        {
            if (action == null)
                throw new ArgumentNullException("action");
            ScheduledItem<DateTimeOffset, TState> si = null;
            Func<IScheduler, TState, IDisposable> action2 = delegate(IScheduler scheduler, TState state1) {
                _queue.Remove((ScheduledItem<DateTimeOffset>)si);
                return action(scheduler, state1);
            };
            si = (ScheduledItem<DateTimeOffset, TState>)new ScheduledItem<DateTimeOffset, TState>((IScheduler)this, state, action2, dueTime, base.Comparer);
            _queue.Enqueue((ScheduledItem<DateTimeOffset>)si);
            return si;
        }
    }
}