Re: Need help solving a threading issue
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
news:lp0ta3p3m5megn6eooto9c6bfv1u97stde@4ax.com...
Yes. It does the right thing, and if everything goes right, there is no
problem. But if
you introduce locking, or the thread blocks, or there are interdepencies
(such as a
SendMessage back to the blocked thread) you get deadlock. It's one of
those things that
is very, very fragile, and works perfectly under very limited assumptions.
But a minor
change in the program can violate those assumptions, then the program
breaks horribly, and
it can be difficult to track down, especially if the lockup occurs under
odd conditions,
such as when an error occurs.
User-visible HWNDs deal with additional problems such as interacting with
the user,
message routing, etc., and if they are popups or child windows, you have
an even more
fragile situation.
Essentially, I compare using interthread SendMessage and putting
user-visible windows in a
secondary thread to juggling bowling balls on thin ice. Everything works
well until you
miss one.
joe
Ha ha, that's a good visual! :-). Actually, I think we ended up replacing
SendMessage with PostMessage due to the caller not needing to be synchronous
(it did not need to wait for the message to be processed before continuing.)
-- David