Ensuring Verb Completion

Your program can create the appearance of an indefinite wait if it mishandles verb completion. If the program starts a verb, fails to note that the verb completed synchronously, and waits for asynchronous completion, the program will wait forever.

The RUI entry points return as their explicit result the primary return code of the verb that was executed. The simplest way to tell whether a verb will be completed asynchronously is to test this explicit return for LUA_IN_PROGRESS, as shown in Figure Testing Verb Completion.

Figure 1. Testing Verb Completion
unsigned short rc;
rc = RUI(ptrToTheVerb);
if (LUA_IN_PROGRESS == rc)
   // verb will complete later; the callback function will be entered
else
   // verb is finished now; the callback function will never be entered