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); }
public override void Add(WrappedEventHandler handler, AutomationElementWrapper element) { _handler = (o, e) => handler(element, e); _element = element.Element; Automation.AddStructureChangedEventHandler(_element, _scope, _handler); }
public abstract void Add(WrappedEventHandler handler, AutomationElementWrapper element);
public override void Add(WrappedEventHandler handler, AutomationElementWrapper element) { _handler = (o, e) => handler(element, e); Automation.AddAutomationFocusChangedEventHandler(_handler); }
private IEnumerable <AutomationEventWrapper> AddPulsingHandlers(IEnumerable <AutomationEventWrapper> eventWrappers, AutomationElementWrapper element) { foreach (var wrapper in eventWrappers) { wrapper.Add((src, e) => { _triggeringEvent = e; PulseTheWaitingRoom(); }, element); } return(eventWrappers); }
public override void Add(WrappedEventHandler handler, AutomationElementWrapper element) { _element = element.Element; _handler = (o, e) => handler(element, e); Automation.AddAutomationPropertyChangedEventHandler(_element, _scope, _handler, _properties); }