Exemplo n.º 1
0
 public static bool WaitUntilAsserted(WaitCondition condition, int timeout, string message)
 {
     if (!WaitUntil(condition, timeout))
     {
         throw new Exception(message);
     }
     return(true);
 }
Exemplo n.º 2
0
    IEnumerator DoWaitFor(WaitCondition waitCondition, Action callback)
    {
        while (waitCondition() == false)
        {
            yield return(null);
        }

        callback.TryInvoke();
    }
Exemplo n.º 3
0
 public WaitOperation(
     NsScriptThread thread,
     WaitCondition condition,
     EntityQuery?entityQuery)
 {
     Thread      = thread;
     Condition   = condition;
     EntityQuery = entityQuery;
 }
Exemplo n.º 4
0
 public static void Wait(WaitCondition condition, WaitAction action)
 {
     if (condition())
     {
         action();
     }
     else
     {
         _waiting.Add(new Tuple <WaitCondition, WaitAction>(condition, action));
     }
 }
Exemplo n.º 5
0
        public bool WaitUntilCallback(Action submitter, WaitCondition waiter)
        {
            while (!bAborted && !waiter())
            {
                submitter();

                int seq = this.seq;
                do
                {
                    WaitForCallbacks();
                }while (!bAborted && this.seq == seq && !waiter());
            }

            return(bAborted);
        }
Exemplo n.º 6
0
        public static void WaitForCondition(WaitCondition condition, int maxWaitMillis = 10000)
        {
            const int sleepMillis  = 100;
            var       millisWaited = 0;

            while (!condition() && millisWaited < maxWaitMillis)
            {
                Thread.Sleep(sleepMillis);
                millisWaited += sleepMillis;
            }

            if (millisWaited >= maxWaitMillis)
            {
                Assert.Fail("Timeout reached.");
            }
        }
Exemplo n.º 7
0
        internal static void WaitForCondition(WaitCondition condition)
        {
            const int totalTimeout   = 60000;
            const int step           = 1000;
            int       currentTimeout = 0;

            while (condition() == false && currentTimeout < totalTimeout)
            {
                Thread.Sleep(step);
                currentTimeout += step;
            }

            if (currentTimeout >= totalTimeout)
            {
                throw new Exception("Timeout reached while waiting on a thread.");
            }
        }
Exemplo n.º 8
0
        public static bool WaitUntil(WaitCondition condition, int timeout)
        {
            DateTime now = DateTime.Now;

            while (true)
            {
                if (condition())
                {
                    return(true);
                }

                if ((DateTime.Now - now).TotalMilliseconds > timeout)
                {
                    return(false);
                }
                Thread.Sleep(100);
            }
        }
        public ConfigCommand AddCommand <T>(WaitCondition waitCondition) where T : Resource.EC2.Instancing.Metadata.Config.Command.Command, new()
        {
            var returnValue = this.AddCommand <Resource.EC2.Instancing.Metadata.Config.Command.Command>($"SignalComplete{waitCondition.LogicalId}");

            if (string.IsNullOrEmpty(waitCondition.LogicalId))
            {
                throw new InvalidOperationException();
            }
            var logFile = $"c:\\cfn\\log\\{waitCondition.LogicalId}.log";

            returnValue.Command = new FnJoin(FnJoinDelimiter.None,
                                             "cfn-signal.exe -e 0 \"",
                                             new ReferenceProperty(waitCondition.Handle),
                                             $"\">{logFile}");
            returnValue.Test = $"IF EXIST \"{logFile}\" EXIT /B 1";
            returnValue.WaitAfterCompletion = 0.ToString();

            return(returnValue);
        }
Exemplo n.º 10
0
        internal void Condition(Action action, WaitCondition waitCondition, int waitTimeout)
        {
            var oldUrl = Browser.Window.Url;

            action.Invoke();
            switch (waitCondition)
            {
            case WaitCondition.None:
                break;

            case WaitCondition.Sleep:
                Thread.Sleep(waitTimeout);
                break;

            case WaitCondition.Ajax:
                if (waitTimeout == 0)
                {
                    WhileAjax(ajaxInevitable: true);
                }
                else
                {
                    WhileAjax(waitTimeout, ajaxInevitable: true);
                }
                break;

            case WaitCondition.PageInProgress:
                WhilePageInProgress(waitTimeout);
                break;

            case WaitCondition.Alert:
                ForHtmlAlert(waitTimeout);
                break;

            case WaitCondition.Redirect:
                ForRedirect(oldUrl);
                break;

            case WaitCondition.NewWindow:
                ForWindow(waitTimeout);
                break;
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// returns true if control meets specified condition before time-out; otherwise, false.
 /// </summary>
 public bool WaitForControlCondition(WaitCondition condition)
 {
     return WaitForControl(condition, elementIsValid);
 }
Exemplo n.º 12
0
 public IWebControl FindElementBy(FindByType criteria, string textCriteria, Type type, WaitCondition waitCondition)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 13
0
 public void WaitControl(FindByType criteria, string textCriteria, WaitCondition condition)
 {
 }
Exemplo n.º 14
0
        public bool WaitUntilCallback(Action submitter, WaitCondition waiter)
        {
            while (!bAborted && !waiter())
            {
                submitter();

                int seq = this.seq;
                do
                {
                    WaitForCallbacks();
                }
                while (!bAborted && this.seq == seq && !waiter());
            }

            return bAborted;
        }
Exemplo n.º 15
0
 public void WaitControl(FindByType criteria, string textCriteria, WaitCondition condition)
 {
     var element = GetWebElement(criteria, textCriteria, condition.WaitingConditionType, condition.Timeout);
     //control = GetWebControl(criteria, type, element);
     //return element;
 }
Exemplo n.º 16
0
 public void AddDependsOn(WaitCondition waitConditionHandle)
 {
     this.DependsOn.Add(waitConditionHandle.LogicalId);
 }
Exemplo n.º 17
0
        public bool WaitForControl(WaitCondition loopCondition, WaitCondition returnCondition)
        {
            int totalTime = 0;
            AutomationElement uiControl = null;

            try
            {
                do
                {
                    DetermineMatchingElement();
                    uiControl = matchingElement;

                    totalTime += sleepIncrement;
                    Thread.Sleep(sleepIncrement);
                }
                while (loopCondition(uiControl) && totalTime < TimeoutValue());
            }
            catch (ElementNotAvailableException)
            {
                return false;
            }

            return returnCondition(uiControl) && totalTime < TimeoutValue();
        }
Exemplo n.º 18
0
        private IEnumerable<FarmServerStats> ChangeState(Action<StateExecutor> changeState, Action<object> writeObject = null, WaitCondition waitCondition = null)
        {
            var stats = new List<FarmServerStats>();

            foreach (var farm in Farms)
            {
                foreach (var server in farm.Servers)
                {
                    using (var arr = new ArrServerManager(server.WebFarm, server.Name))
                    {
                        changeState(arr.StateExecutor);
                        arr.Commit();

                        if(waitCondition != null)
                        {
                            while(waitCondition(arr.Counters))
                            {
                                Thread.Sleep(100);
                            }
                        }
                        if(writeObject != null)
                        {
                            writeObject(arr.Counters.GetServerStats());
                        }
                    }
                }
            }
            return stats;
        }
Exemplo n.º 19
0
        private IEnumerable <FarmServerStats> ChangeState(Action <StateExecutor> changeState, Action <object> writeObject = null, WaitCondition waitCondition = null)
        {
            var stats = new List <FarmServerStats>();

            foreach (var farm in Farms)
            {
                foreach (var server in farm.Servers)
                {
                    using (var arr = new ArrServerManager(server.WebFarm, server.Name))
                    {
                        changeState(arr.StateExecutor);
                        arr.Commit();

                        if (waitCondition != null)
                        {
                            while (waitCondition(arr.Counters))
                            {
                                Thread.Sleep(100);
                            }
                        }
                        if (writeObject != null)
                        {
                            writeObject(arr.Counters.GetServerStats());
                        }
                    }
                }
            }
            return(stats);
        }
Exemplo n.º 20
0
 void WaitFor(WaitCondition condition, Action callback)
 {
     StartCoroutine(DoWaitFor(condition, callback));
 }