Пример #1
0
 public void throwIfTimedOutOrCancelled(string cancellationMessage = null)
 {
     if (!stillOK)
     {
         string        stackTrace = Environment.StackTrace;
         List <string> split      = stackTrace.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries).ToList();
         split.Remove("   at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)");
         split.Remove("   at System.Environment.get_StackTrace()");
         string stackTraceTrimmed = string.Join("\r", split);
         throw new TimeoutException(cancellationMessage + " @ " + stackTraceTrimmed);
     }
     if (childDeadline != null)
     {
         childDeadline.throwIfTimedOutOrCancelled(cancellationMessage);
     }
 }
Пример #2
0
        public override void WaitForStatus(bool isPowerOn, cancellableDateTime deadline)
        {
            if (isPowerOn)
            {
                doWithRetryOnSomeExceptions(() =>
                {
                    executor.testConnectivity();
                    return(0);
                }, deadline);
            }
            else
            {
                while (true)
                {
                    if (getPowerStatus() == false)
                    {
                        break;
                    }
                    deadline.throwIfTimedOutOrCancelled();

                    deadline.doCancellableSleep(TimeSpan.FromSeconds(1));
                }
            }
        }