Re: MDI with child windows controlled by processes?
"L.Allan" <l.allan@worldnet.att.net> wrote in message
news:u8XYLCBRIHA.3400@TK2MSFTNGP03.phx.gbl...
I'm trying to update an SDI app so that it can take advantage of
multi-core cpu's to do parallel searching of 2 to 20+ relatively large
files. The searching is independent enough that separate processes work
well, and this relatively inexperienced multi-threader has found this
simpler to get sort-of-working than a threaded-approach with one process
and several threads.
I'm considering an approach that involves MDI, with a child window for
each of the files being searched. However, I'm fuzzy on whether the child
windows can be associated with separate processes.
Here is a scenario:
The "parent" would get the specifications for the search ... such as
case-insensitive regex for "first.+second.+(third|fourth)". Then it would
somehow or other broadcast this spec to the child processes, with the
results displayed in the child windows. The "parent" only needs to be
informed when all the "children" are done ... everything else is
indepedent.
Does this sound feasible ... or flawed? How would I get started to try it
out?
This is not really possible. Child windows should be in the same thread as
their parent window, and must be in the same process as their parent window.
You should really separate the searching and the windows in your thinking.
You can certainly perform searches in multiple threads, but putting
interrelated windows in those threads will lead to thread stalls and
possibly to deadlocks. The problem is that parent/child windows communicate
with each other, and if they are in separate threads each communication
attempt blocks one thread waiting for the other window's thread to do
something.
The best approach would put all windows in the main thread. The search
threads would have no interaction with windows except for PostMessage to ask
the main thread to update a window. This will let the search threads run
unimpeded. Code details to do this are here:
http://vcfaq.mvps.org/mfc/12.htm
--
Scott McPhillips [VC++ MVP]