Method ToTimeSpanForTimerInterval
ToTimeSpanForTimerInterval(Duration)
Converts a NodaTime.Duration to TimeSpan for interval timer registration, timer
Change operations, and virtual clock deltas so behavior matches IPrimeClock
TimeSpan-based timer registration overloads.
public static TimeSpan ToTimeSpanForTimerInterval(Duration duration)
Parameters
durationDurationThe duration to convert (initial delay, repeat interval, or virtual time delta).
Returns
- TimeSpan
MaxValue when
durationis strictly positive and does not fit in a TimeSpan; otherwise the result of NodaTime.Duration.ToTimeSpan().
Remarks
Unlike ToTimeSpanForDelay(Duration) and ToTimeSpanForCancellationToken(Duration), zero and negative durations are not mapped to Zero; they use NodaTime.Duration.ToTimeSpan() so Noda NodaTime.Duration overloads stay aligned with BCL TimeSpan values passed into shared timer and virtual-time registration (including non-positive and sentinel spans such as InfiniteTimeSpan).
Exceptions
- OverflowException
Thrown by NodaTime.Duration.ToTimeSpan() when
durationis not representable as a TimeSpan.