TimeoutUtil
using System;
using System.Runtime.CompilerServices;
using System.Threading;
namespace Polly.Timeout
{
internal static class TimeoutUtil
{
[System.Runtime.CompilerServices.Nullable(1)]
public const string TimeSpanInvalidMessage = "The '{0}' must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).";
public static bool ShouldApplyTimeout(TimeSpan timeout)
{
return timeout > TimeSpan.Zero;
}
public static bool IsTimeoutValid(TimeSpan timeout)
{
if (timeout > TimeSpan.Zero)
return true;
if (!(timeout == System.Threading.Timeout.InfiniteTimeSpan))
return timeout > TimeSpan.Zero;
return true;
}
}
}