예제 #1
0
파일: Waiter.cs 프로젝트: pako4u2k/wipflash
        public bool WaitFor(AutomationElementWrapper element, SomethingToWaitFor check, TimeSpan timeout, FailureToHappenHandler failureHandler, IEnumerable <AutomationEventWrapper> events)
        {
            Monitor.Enter(_waitingRoom);
            _triggeringEvent = null;

            DateTime started         = DateTime.Now;
            var      handlerRemovers = AddPulsingHandlers(events, element);

            bool checkPassed = true;

            while (!check(element, _triggeringEvent) && DateTime.Now.Subtract(started).CompareTo(timeout) < 0)
            {
                checkPassed = false;
                Monitor.Wait(_waitingRoom, timeout);
            }
            Monitor.Exit(_waitingRoom);
            ClearPulsingHandlers(handlerRemovers);

            if (!checkPassed && !check(element, null))
            {
                failureHandler(element);
                return(false);
            }
            return(true);
        }
예제 #2
0
 public override void Add(WrappedEventHandler handler, AutomationElementWrapper element)
 {
     _handler = (o, e) => handler(element, e);
     _element = element.Element;
     Automation.AddStructureChangedEventHandler(_element, _scope, _handler);
 }
예제 #3
0
 public abstract void Add(WrappedEventHandler handler, AutomationElementWrapper element);
예제 #4
0
 public override void Add(WrappedEventHandler handler, AutomationElementWrapper element)
 {
     _handler = (o, e) => handler(element, e);
     Automation.AddAutomationFocusChangedEventHandler(_handler);
 }
예제 #5
0
파일: Waiter.cs 프로젝트: pako4u2k/wipflash
 private IEnumerable <AutomationEventWrapper> AddPulsingHandlers(IEnumerable <AutomationEventWrapper> eventWrappers, AutomationElementWrapper element)
 {
     foreach (var wrapper in eventWrappers)
     {
         wrapper.Add((src, e) =>
         {
             _triggeringEvent = e;
             PulseTheWaitingRoom();
         }, element);
     }
     return(eventWrappers);
 }
예제 #6
0
 public override void Add(WrappedEventHandler handler, AutomationElementWrapper element)
 {
     _element = element.Element;
     _handler = (o, e) => handler(element, e);
     Automation.AddAutomationPropertyChangedEventHandler(_element, _scope, _handler, _properties);
 }