UI Automation Threading Issues
Actualización: noviembre 2007
Because of the way Automatización de la interfaz de usuario de Microsoft uses Windows messages, conflicts can occur when a client application attempts to interact with its own interfaz de usuario on the interfaz de usuario thread. These conflicts can lead to very slow performance or even cause the application to stop responding.
If your client application is intended to interact with all elements on the desktop, including its own interfaz de usuario, you should make all Automatización de la interfaz de usuario calls on a separate thread. This includes locating elements (for example, by using TreeWalker or the FindAll method) and using control patterns.
It is safe to make Automatización de la interfaz de usuario calls within a Automatización de la interfaz de usuario event handler, because the event handler is always called on a non-interfaz de usuario thread. However, when subscribing to events that may originate from your client application's interfaz de usuario, you must make the call to AddAutomationEventHandler, or a related method, on a non-interfaz de usuario thread. Remove event handlers on the same thread.