Re: multithreaded dialog application



But see my essay http://www.flounder.com/kb192570.htm on receiving network data in
multiple threads, a rewrite of the piece of crap in the MSDN.

(I also cited my essay on the use of I/O Completion ports, so here's the link to it...
http://www.flounder.com/iocompletion.htm )
joe

On Fri, 29 Jun 2007 11:37:22 -0400, "Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp>
wrote:

Ryan wrote:
My application is a dialog app, with one parent dialog with spawns
several (up to 20 or so) child dialogs. There are basically three
channels of input to the dialogs: user actions and messages that come
in on two seperate threads via socket connections. At this point, all
the socket messages are posted to the main thread to be processed.
Nearly all the socket messages are simply passed on to a child dialog
(or 3 or 4 in some instances) to be processed.

The number of messages received from the sockets can be quite large
and since they come in on two seperate threads, I think it would be
more efficient to handle these messages in multiple threads (this is a
realtime application so we want to reduce latency in processing
messages as much as possible). There is some calculation that is done
to process the various messages that could be pushed to a worker
thread, but nearly every message results in a UI update as well.

My understanding is that there is no safe way to update the UI from
any threads other than the main thread. I'd like to know if this is
correct. It's not clear from what I read, but I'm hoping it may be
possible to create child dialogs in a seperate UI thread. If this
could be done for even one dialog, I believe we would derive
significant benefit from this. My concern is in still being able to
link the child dialog back to the parent dialog if they are in
seperate threads.

Can anyone give some advice on what possible options I have or if I am
really stuck posting everything to the main thread?

It's not clear what you are trying to fix. You can't have a parent
window in one thread and child windows in a different thread.

If you have significant latency then perhaps you have too many messages
stacking up between the threads. If that is the case look for ways to
combine messages. You may also be able to do the update painting more
efficiently: Are you painting more than you need to paint when you do an
update?

Your assumption that more threads would help is quite questionable. More
threads add more overhead and reduce the time available to the main
thread for painting. If you have only one network interface then there
is little or nothing to be gained by having multiple socket threads:
Only one network message can arrive at a time.
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • [PATCH 1/1] IPN: Inter Process Networking
    ... +IPN is an Inter Process Communication service. ... +interface and protocols used for networking. ... +to a "network". ... +creates a communication socket. ...
    (Linux-Kernel)
  • Re: [PATCH 1/1] IPN: Inter Process Networking
    ... +IPN is an Inter Process Communication service. ... +interface and protocols used for networking. ... +to a "network". ... +creates a communication socket. ...
    (Linux-Kernel)
  • Re: Home Networking
    ... has 4 network sockets) in the roofspace and then wire a CAT5 network ... NTE5 master socket, so I don't need a filter at each phone outlet. ... A number of different suppliers offer such equipment, including Solwise whose range I use including their Homeplug ADSL Modem Router. ...
    (uk.telecom.broadband)
  • Network freezes up
    ... PROBLEM: Network freezes up. ... Client side machine ok. ... Reboot the server machine cures the problem for a while. ... socket classes, not based on MFC. ...
    (microsoft.public.win32.programmer.networks)
  • TCP Server+perl
    ... Client each time a new connection is established at the Socket. ... each child completes processing it closes/ends. ... # Main loop control variable ... You exit the ...
    (comp.lang.perl.misc)