Tech Support > Microsoft Windows > Development Resources > MsgWaitForMulptipleObjects() vs Sleep()
MsgWaitForMulptipleObjects() vs Sleep()
Posted by Bob on July 17th, 2003


How do I use MsgWaitForMultipleObjects?
particularly I need help with the first 2 parameters.

My program is hanging on some computers (seems like only win. XP)

So I am trying to find the problem, I think it is because I am calling sleep
and using threads and COM which the docs said my be a problem.

So basically I have 2 threads (at least) one is for the gui the other is for
doing the work. One of the functions in the worker thread is a loop that
checks a pop3 account and I want to wait 5 minutes after I check and then go
back and loop again. is parameter 2 supposed to be a handle to the worker
thread?


thanks for any help

Bob


Posted by Tim Robinson on July 17th, 2003


The values you pass in the first two parameters depend on what you're
waiting on. Typically you'll build up an array of HANDLEs to various
objects, and pass a pointer to the array and the number of elements to
MsgWaitForMultipleObjects. Unless there's something you've got to wait for
there's no reason to use MsgWaitForMultipleObjects.

(Passing a handle to a thread to any wait function will cause the wait to
finish when the thread exits.)

--
Tim Robinson (MVP, Windows SDK)
http://www.themobius.co.uk/

"Bob" <rbonham@rREMOVETHISaustin.rr.com> wrote in message
news:UeERa.81952$xg5.77023@twister.austin.rr.com.. .


Posted by Sten Westerback on July 18th, 2003



"Bob" <rbonham@rREMOVETHISaustin.rr.com> wrote in message
news:UeERa.81952$xg5.77023@twister.austin.rr.com.. .
is and the second points to that handle array. Make sure
all the array elements has valid values!

for one or all objects?

deadlock..

without problems... or do you wait INFINITE in it?

Maybe you should consider some other object to wait for like an event,
mutex or waitable timer.

If you need more help, post some code fragments!

- Sten



Posted by Bob on July 18th, 2003


thank you for the furthur clarification!

I will post code if I find I need more help,

Bob

"Sten Westerback" <sten.westerback@NO_SPAMnokia.com> wrote in message
news:rWLRa.7786$g4.152505@news1.nokia.com...



Similar Posts