private void InternalCancelAfter(TimeSpan delay)
{
ThrowIfDisposed();
if(_source.IsCancellationRequested)
return;
//If the scheduler is using the system time, we can optimize for that
if(_scheduler is IDateTimeOffsetNowTimeProvider)
{
//Use the built in functionality on CancellationTokenSource which is
//likely more lightweight than using the scheduler
_source.CancelAfter(delay);
}
else
{
_scheduler.ScheduleOnce(delay, () => _source.Cancel(), this);
}
}