/// <summary> /// Adds a property changed automation event handler /// </summary> /// <param name="hWnd">window handle</param> /// <param name="property">the property to track</param> /// <param name="element">the element in the window to track</param> /// <param name="eventHandler">the event handler</param> static public void AddAutomationPropertyChangedEventHandler(IntPtr hWnd, AutomationProperty property, AutomationElement element, AutomationPropertyChangedEventHandler eventHandler) { lock (WindowTable) { var windowElement = (WindowElement)WindowTable[hWnd]; if (windowElement == null) { windowElement = new WindowElement(hWnd); WindowTable.Add(hWnd, windowElement); windowElement.EvtOnWindowClosed += windowElement_EvtOnWindowClosed; } var item = new AddAutomationPropertyChangedItem { Property = property, AutoElement = element, EventHandler = eventHandler, WinElement = windowElement }; AddAutomationPropertyChanged(item); } }
/// <summary> /// Enqueues the item for asynchronous handling /// </summary> /// <param name="item">item to add</param> private static void AddAutomationPropertyChanged(AddAutomationPropertyChangedItem item) { _instance._queue.Enqueue(item); }