CompuServe Messages

#Wait problem continued

    02-Oct-92 15:38:26
Fm: Vic Wagner 76046,3004
To: Jim Shaffer Jr. 72750,2335
Jim, It's not clear that it IS ignoring the Wait(). The example for writing an IDCMP 'loop' is perhaps a bit unclear. One thing is certain tho, you NEVER Reply() with a NULL as an argument… the loop SHOULD look like: while (notdone) { Wait(1<<window->UserPort->mp_SigBit); while (msg = GetMsg(window->UserPort) { …do all your message processing here …it probably is a switch statement to handle … all of the possible message 'types' … SOMETHING in here must set 'notdone' to false if you ever … want the loop to terminate Reply(msg); // if you feel compelled to Reply() earlier // you MUST copy the relevant information from // the msg structure, since it MAY be destroyed // as soon as the message is Reply()d } } A careful reading of how the Signal() and Wait() functions DO work will show that (using the above loops) you CAN get calls to GetMsg() which will return NULL even immediately AFTER the Wait() returns. Now to address YOUR problem specifically. You say you ONLY call Wait() if you check for a message, find one, and check for another message and do NOT find one. Right?? If this is the case, the Signal bit is STILL set in the port. Wait() is the ONLY function which clears the bits, so the scenario I envision would almost guarantee the guru in your program. Write the loop as I've shown above, it's MUCH safer…and look for the mousebutton 'up' message to set the notdone flag to false.