On Aug 27, 7:00 pm, Joseph M. Newcomer <newco...@flounder.com> wrote:
You should not be doing such high-frequency I/O in the main GUI
thread. And you should
not be considering PeekMessage as a solution; do the I/O in a
separate thread.
You can explicitly call UpdateWindow after making modifications, but
the problem is much
deeper than just a screen update. You have a very high interaction
rate. Even if you are
using separate threads and using PostMessage to post messages to the
main GUI thread, this
means that you always have something in the message queue, since you
will be having
updates sent, on the average, every 100us (10 clients with 1ms
updates), so the WM_PAINT,
which is not sent until the queue is empty, is never sent. In
addition, given the high
data rate, there is a chance you could start losing messages. See my
essay on the use of
I/O Completion Ports to avoid this problem, on my MVP Tips site.
If you move sockets to separate threads, check out my essay on
multithreaded sockets (do
not trust the MSDN article, which is buggy beyond usability). If you
are trying to
support this data rate in a single thread, you are going to have
problems with saturating
the thread's capability to respond to user input.
Given this high data rate, and the inability of users to see anything
updating too
quickly, you might be better off just recording the values in an
array, and on a WM_TIMER
notification, perhaps 20 times a second or even less, updating the
display. (This won't
work if everything is in the main thread because you still need the
WM_PAINT, so you would
have to also call UpdateWindow). If you store the information in an
aligned DWORD, you
don't even need to synchronize the reading from and writing to the
array (except to extend
it), because the hardware will do that, and if you miss an update,
you'll catch it the
next time around.
joe
On Mon, 27 Aug 2007 09:31:04 -0700, RAN <nijenh...@wish.nl> wrote:
Hi,
I have a serverprogram with a CListCtrl, displaying 2 collumns with
BytesIn and BytesOut.
Those BytesIn and BytesOut represent the number of bytes comming in
and going out of the server socket. If i startup 10 clients that
connect to the server, they al send about 100 bytes of data at a 1ms
interval. The problem is that my server GUI is not getting updated,
how do i get this done? Is it something with PeekMsg() ? I dont want
to make everything threaded...
Joseph M. Newcomer [MVP]
email: newco...@flounder.com
Web:http://www.flounder.com
MVP Tips:http://www.flounder.com/mvp_tips.htm
it won't work at all whithout them i guess.
program work the way it suppose to work. Can i download the source of