Re: MDI with child windows controlled by processes?
- From: "Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp>
- Date: Fri, 21 Dec 2007 19:19:35 -0500
"L.Allan" <l.allan@xxxxxxxxxxxxxxxx> wrote in message news:u8XYLCBRIHA.3400@xxxxxxxxxxxxxxxxxxxxxxx
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]
.
- References:
- MDI with child windows controlled by processes?
- From: L.Allan
- MDI with child windows controlled by processes?
- Prev by Date: Re: CSingleLock doesn't seem to work
- Next by Date: Re: CSingleLock doesn't seem to work
- Previous by thread: Re: MDI with child windows controlled by processes?
- Next by thread: Re: MDI with child windows controlled by processes?
- Index(es):
Relevant Pages
|