After adding the request to the server's queue, the requester is notified by the server when the request has been serviced. This is done using a Presentation Manager message, since the requester's window handle is passed to the server in the second parameter to the DosWriteQueue() function. The operating system imbeds this value as the second doubleword of a REQUESTDATA structure which is passed to the server by the DosReadQueue() function.
Once notification is received from the server process, the requester uses the DosReadQueue() function to retrieve the returned data from its own queue, as shown in Figure "Interprocess Communication Using Queues (Part 3)".
The DCWW_WAIT flag causes the DosReadQueue() function to wait until an element is available in the queue before returning control to the application. If the process merely wishes to check whether a queue element is available, the DCWW_NOWAIT flag may be specified, in which case an event semaphore must be created and its handle passed to the DosReadQueue() function. This semaphore is immediately set by the operating system, and is posted when an element is added to the queue. If the queue is shared between processes (as in the examples given herein), the semaphore must be shared, either by creating it as a named semaphore or by setting the DC_SEM_SHARED flag in the DosCreateEventSem() call.
It will be noted that the use of queues is very similar to that of shared memory, except that the queue is used to pass a pointer to a shared memory object, rather than a Presentation Manager message. However, queues have an advantage in that they may be FIFO, LIFO or priority-based, without the need for the application to handle the querying and sorting of elements.