After we generate the print step (to print or generate a file/virtual printer) and immediately after that we have more related code to continue, we have to wait for the queue to complete...
With a function to query the queue (pending, canceled, ...), we can create our loop and determine the flow in our code.