Re: Child / Parent windows not in same thread
On Thursday, June 21, 2012 1:35:53 PM UTC-4, Maja wrote:
On Jun 21, 5:05 pm, "ScottMcP [MVP]" <scott...@mvps.org> wrote:
But, if I can be sure that both the message loops of the main thre=
ad
and my second thread are alive, and I don't hold any locks , I can ge=
t
away without this deadlocks problems ? or no
It would probably work if, as you say, both the message loops are alive=
.. But it's not good enough for your thread to hold no locks. The main threa=
d also has to hold no locks.
Thank you for quick reply
One more question
Now after I think more , maybe I can't be that sure, so I am in a
doubt if I should do this thread thing at all.
I found the following post
http://groups.google.com/group/microsoft.public.win32.programmer.ole/brow=
se_thread/thread/f4d67cb4d0b085c0/8f463a49544f48fc?lnk=gst&q=Validity+o=
f+creating+a+child+window+in+a+separate+process#8f463a49544f48fc
which suggests that creating the window as WS_POPUP instead as
WS_CHILD is more secure, so if this is true does it mean that no
chance for deadlocks exists ?
Using WS_POPUP, and passing NULL as the hwndParent, will make sure that you=
r window will not have a parent/child relationship with the main thread win=
dows. However, you are still subject to possible deadlocks if you SendMess=
age to any window created in another thread.
The combination of WS_POPUP and never using SendMessage to the other thread=
should make you safe from deadlocks. (And it is OK to use PostMessage to =
the other thread.)