I am reviewing some code where MTA threads are calling making a call to EnumThreadWindows with their thread ID and looking for a Window with a particular class name. This window is created by an STA COM object explicitly for the purpose of tying an MTA thread to a itself.
I'm sure this works great when there's a single STA object (and therefore only one window); however, in the scenario where there are 8 of these windows and because these are non-GUI MTA threads I am wondering how can these threads be associated with a specific window. We don't create these, they're part of a thread pool in Internet Explorer relating to asynchronous pluggable protocol handling.
Unless I'm missing some 'magic' I would think that the EnumThreadWindows call would result in all windows in the process being enumerated because the threads are non-GUI threads.
I've done some initial exploration of this; however, the scenario in which these operations happen in our code is fairly complicated and doesn't lend it self well to this.
Is the enumeration behavior of EnumThreadWindows explained in more detail than what we see in MSDN?