FromTimeSpan() public static method

public static FromTimeSpan ( System.TimeSpan duration ) : long
duration System.TimeSpan
return long
Beispiel #1
0
        public static TimeSpan Divide(TimeSpan timeout, int factor)
        {
            if (timeout == TimeSpan.MaxValue)
            {
                return(TimeSpan.MaxValue);
            }

            return(Ticks.ToTimeSpan((Ticks.FromTimeSpan(timeout) / factor) + 1));
        }
Beispiel #2
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));
     }
 }
Beispiel #3
0
 public static TimeSpan Add(TimeSpan timeout1, TimeSpan timeout2)
 {
     return(Ticks.ToTimeSpan(Ticks.Add(Ticks.FromTimeSpan(timeout1), Ticks.FromTimeSpan(timeout2))));
 }