Table of Contents

Method ToTimeSpanForDelay

Namespace
KZDev.PrimeTime
Assembly
KZDev.PrimeTime.dll

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

duration Duration

The duration to convert.

Returns

TimeSpan

Zero when duration is zero or negative, MaxValue when it exceeds the BCL representable range, otherwise the equivalent span.

Exceptions

OverflowException

Thrown by NodaTime.Duration.ToTimeSpan() when duration is not representable as a TimeSpan in the branch that calls it.