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

VirtualTimeSchedulerExtensions

public static class VirtualTimeSchedulerExtensions
Provides a set of extension methods for virtual time scheduling.
using System.Reactive.Disposables; using System.Runtime.CompilerServices; namespace System.Reactive.Concurrency { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] public static class VirtualTimeSchedulerExtensions { public static IDisposable ScheduleRelative<[System.Runtime.CompilerServices.Nullable(0)] TAbsolute, [System.Runtime.CompilerServices.Nullable(2)] TRelative>(this VirtualTimeSchedulerBase<TAbsolute, TRelative> scheduler, TRelative dueTime, Action action) where TAbsolute : IComparable<TAbsolute> { if (scheduler == null) throw new ArgumentNullException("scheduler"); if (action == null) throw new ArgumentNullException("action"); return scheduler.ScheduleRelative(action, dueTime, (IScheduler _, Action a) => Invoke(a)); } public static IDisposable ScheduleAbsolute<[System.Runtime.CompilerServices.Nullable(0)] TAbsolute, [System.Runtime.CompilerServices.Nullable(2)] TRelative>(this VirtualTimeSchedulerBase<TAbsolute, TRelative> scheduler, TAbsolute dueTime, Action action) where TAbsolute : IComparable<TAbsolute> { if (scheduler == null) throw new ArgumentNullException("scheduler"); if (action == null) throw new ArgumentNullException("action"); return scheduler.ScheduleAbsolute(action, dueTime, (IScheduler _, Action a) => Invoke(a)); } private static IDisposable Invoke(Action action) { action(); return Disposable.Empty; } } }