Exemplo n.º 1
0
 public static DateTime GetEndTime(int timeout)
 {
     if (timeout == -1)
     {
         return(DateTime.MaxValue);
     }
     return(UtilityComputingHelper.GetEndTime(TimeSpan.FromMilliseconds((double)timeout)));
 }
Exemplo n.º 2
0
        public static int GetRemainingTimeMilliseconds(DateTime endTime)
        {
            TimeSpan remainingTime = UtilityComputingHelper.GetRemainingTime(endTime);

            if (remainingTime == UtilityComputingHelper.InfiniteTimeoutTimeSpan)
            {
                return(-1);
            }
            return((int)remainingTime.TotalMilliseconds);
        }
Exemplo n.º 3
0
        public static int GetRemainingTimeOrThrow(DateTime endTime)
        {
            int remainingTimeMilliseconds = UtilityComputingHelper.GetRemainingTimeMilliseconds(endTime);

            if (remainingTimeMilliseconds == 0)
            {
                if ((DateTime.UtcNow - endTime).TotalSeconds > UtilityComputingHelper.TimeoutAlertThresholdInSeconds.TotalSeconds)
                {
                    lock (UtilityComputingHelper.s_alertSyncObject)
                    {
                        UtilityComputingHelper.s_timoutCountSinceLastAlert++;
                    }
                }
                throw new TimeoutException();
            }
            return(remainingTimeMilliseconds);
        }