Re: Calling UpdateData(FALSE) in a loop?
Daneel wrote:
Hello!
I'm using a for loop to wait for each of my threads to return:
for (i = 0; i < 6; i++) {
dwEvent = WaitForMultipleObjects(6-i, h, FALSE, INFINITE);
for (j = dwEvent; j < 6; j++) {
h[dwEvent] = h[dwEvent+1];
}
// update user interface of my dialog window
UpdateData(FALSE);
}
As you can see I'm calling UpdateData after each thread returned.
However, the update of the user interface only happens after the
method which includes this for loop finishes.
How can I update the user interface after each thread returns, i.e.,
multiple times in a method?
Many thanks,
Michael
If this code is in your user interface thread, it is blocking your
message loop until all of the other threads exit.
Many portions of the UI will not repaint themselves on the screen until
they receive a WM_PAINT message. Because your message loop is blocked,
no WM_PAINT messages are getting through.
You may be able to make this work by using MsgWaitForMultipleObjects()
instead of WaitForMultipleObjects(). This will return whenever there is
a message in the queue, as well as when any of the threads terminates.
When that happens, you use a secondary message loop which calls
PeekMessage(..., PM_REMOVE) and dispatch any messages that are in the
queue. When PeekMessage() returns FALSE, go back to the
MsgWaitForMultipleObjects() wait.
Norm
--
--
To reply, change domain to an adult feline.