Reputation: 1390
I have a very basic question :
is EnumWindows
thread safe ?
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633497(v=vs.85).aspx
Thanks
Upvotes: 2
Views: 657
Reputation: 942119
Not in the main thread. That was my question
Some functions from user32.dll are thread-sensitive, you can dig yourself a pretty deep hole if you call, say, SendMessage() for a custom message on a worker thread. But no, EnumWindows() has no such problem, it doesn't care whether the thread is pumping a message loop and does not rely on thread state. You do of course need to account for the possibility that the window handle you get in the callback might be for a window that was destroyed just a fraction of a second earlier, EnumWindows() does not freeze every thread of every process that created a window.
Upvotes: 3
Reputation: 613412
You can call EnumWindows
safely from any thread. As a general rule, Windows API functions are thread safe. Exceptions to this general rule will be sign posted in a function's documentation.
Upvotes: 3