Method ToTimeSpanForDelay
ToTimeSpanForDelay(Duration)
Converts a NodaTime.Duration to TimeSpan for BCL delay APIs (Sleep(TimeSpan), Delay(TimeSpan), and related).
public static TimeSpan ToTimeSpanForDelay(Duration duration)
Parameters
durationDurationThe duration to convert.
Returns
- TimeSpan
Zero when
durationis zero or negative, MaxValue when it exceeds the BCL representable range, otherwise the equivalent span.
Exceptions
- OverflowException
Thrown by NodaTime.Duration.ToTimeSpan() when
durationis not representable as a TimeSpan in the branch that calls it.