示例#1
0
 TimeSpan WaitTimeWithDrift()
 {
     return(Ticks.ToTimeSpan(Math.Max(
                                 Ticks.FromTimeSpan(BackoffTimeoutHelper.defaultInitialWaitTime),
                                 Ticks.Add(Ticks.FromTimeSpan(this.waitTime),
                                           (long)(uint)this.random.Next() % (2 * BackoffTimeoutHelper.maxDriftTicks + 1) - BackoffTimeoutHelper.maxDriftTicks))));
 }
示例#2
0
 public void Set(TimeSpan timeFromNow)
 {
     if (timeFromNow != TimeSpan.MaxValue)
     {
         SetAt(Ticks.Add(Ticks.Now, Ticks.FromTimeSpan(timeFromNow)));
     }
 }
示例#3
0
 public static TimeSpan Divide(TimeSpan timeout, int factor)
 {
     if (timeout == TimeSpan.MaxValue)
     {
         return(TimeSpan.MaxValue);
     }
     return(Ticks.ToTimeSpan((Ticks.FromTimeSpan(timeout) / ((long)factor)) + 1L));
 }
示例#4
0
 public static TimeSpan Divide(TimeSpan timeout, int factor)
 {
     if (timeout != TimeSpan.MaxValue)
     {
         return(Ticks.ToTimeSpan(Ticks.FromTimeSpan(timeout) / (long)factor + (long)1));
     }
     else
     {
         return(TimeSpan.MaxValue);
     }
 }
示例#5
0
        public static int ToMilliseconds(TimeSpan timeout)
        {
            if (timeout == TimeSpan.MaxValue)
            {
                return(-1);
            }
            long ticks = Ticks.FromTimeSpan(timeout);

            if ((ticks / 0x2710L) > 0x7fffffffL)
            {
                return(0x7fffffff);
            }
            return(Ticks.ToMilliseconds(ticks));
        }
示例#6
0
 public static int ToMilliseconds(TimeSpan timeout)
 {
     if (timeout == TimeSpan.MaxValue)
     {
         return(Timeout.Infinite);
     }
     else
     {
         long ticks = Ticks.FromTimeSpan(timeout);
         if (ticks / TimeSpan.TicksPerMillisecond > int.MaxValue)
         {
             return(int.MaxValue);
         }
         return(Ticks.ToMilliseconds(ticks));
     }
 }
示例#7
0
 public static int ToMilliseconds(TimeSpan timeout)
 {
     if (timeout != TimeSpan.MaxValue)
     {
         long num = Ticks.FromTimeSpan(timeout);
         if (num / (long)0x2710 <= (long)0x7fffffff)
         {
             return(Ticks.ToMilliseconds(num));
         }
         else
         {
             return(0x7fffffff);
         }
     }
     else
     {
         return(-1);
     }
 }
示例#8
0
 public static TimeSpan Add(TimeSpan timeout1, TimeSpan timeout2)
 {
     return(Ticks.ToTimeSpan(Ticks.Add(Ticks.FromTimeSpan(timeout1), Ticks.FromTimeSpan(timeout2))));
 }
示例#9
0
 private TimeSpan WaitTimeWithDrift()
 {
     return(Ticks.ToTimeSpan(Math.Max(Ticks.FromTimeSpan(defaultInitialWaitTime), Ticks.Add(Ticks.FromTimeSpan(this.waitTime), ((long)(((ulong)this.random.Next()) % ((2L * maxDriftTicks) + 1L))) - maxDriftTicks))));
 }