Table of Contents

Method ToTimeSpanForCancellationToken

Namespace
KZDev.PrimeTime
Assembly
KZDev.PrimeTime.dll

ToTimeSpanForCancellationToken(Duration)

Converts a NodaTime.Duration to TimeSpan for CancellationTokenSource timer limits.

public static TimeSpan ToTimeSpanForCancellationToken(Duration duration)

Parameters

duration Duration

The duration to convert.

Returns

TimeSpan

Zero when duration is zero or negative; otherwise a span capped at int.MaxValue milliseconds when the duration exceeds that limit.

Exceptions

OverflowException

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