AAO DRAMA C++ Interface (Old style)
DRAMA C++, Depreciated, don't use for new code

◆ Wait()

void DcppHandler::Wait ( DitsTransIdType  transId,
StatusType *  status,
double  timeout = 0 
)

Wait for the completion of the action supplied with the transaction id.

This method waits for the action with the given transaction id to complete. The main reason for this implementation is that sometimes, application code wants to issue an OBEY command and then instead of rescheduling the action, it wants to wait for this command/action to run to completion. One may be tempted to structure the code like this : DcppTask.Obey(ACTION_X,&transId....) DitsActionWait(....) DcppDispatch(....)

However, the above code segment may not work correctly when the number of messages which will be outstanding at any one time is greater than one i.e (thread count > 1). This is because the above code segment does not decrement the thread count when the action is finished.

The correct way of acheiving the above result is : DcppTask.Obey(ACTION_X,&transId....) DcppHandler.Wait(transId);

What the Wait() method does is as described below : (i) invokes DitsActionWait() on the supplied transaction id. (ii) invokes HandleReschedule() which in turns calls DcppDispatch(). It also correctly manages the thread count by decrementing the thread count by one everytime the DcppHandlerRoutine returns DcppFinished. (iii) If for any reason the DcppHandler object does not want to wait for more events, but your target event has not been seen, then the status will be set to DCPP__WAITFAIL. (other then timeout events, see timeout argument)

Remarks
Beware that if you invoke this function from a DcppTask message response handler function, then you must have incremented the thread count for each message you sent from that handler function. (Adding a DcppHandler.NewThread() call before the wait in the above example) You would then normally return DcppFinished from the invoking handler function.
Parameters
transIdtransaction id of the action which is pending for completion
statusInherited status
timeoutif positive, this is the timeout to apply for wait operation. If this is triggered, then the Timeout handler associated with the DcppHandler object is triggred. The default handler will set the status to DCPP__TIMEOUT. In eiter case, DitsGetEntReason() will return DITS_REA_RESCHED.