我正在使用C#UI自动化库并尝试将事件处理程序附加到窗口,我正在观察结构何时发生变化。我目前遇到了性能问题,因为触发事件大约需要1.5秒。我使用的代码如下:
AutomationElement window = AutomationElement.FromHandle(processes[0].MainWindowHandle);
Automation.AddStructureChangedEventHandler(window, TreeScope.Children, new StructureChangedEventHandler(OnStructureChanged));
我猜测TreeScope.Children需要一段时间才能完成触发事件?如果是,或者如果不是,那么使这个事件更快地触发的最佳方法是什么?