Waiting for Asynchronous Method Calls to Complete
When the asynchronous method call is executing in the worker application, the application that originated the request continues to execute instructions following the invocation of the asynchronous method call.
The
A method context object whose
A maximum of 64 processing method context objects can be passed to the waitForMethods method.
The following diagram shows a period of parallel processing when the asynchronous method call is executing at the same time as the method in the originating application. The originating application then calls the
The following code fragment shows the use of the
vars context: JadeMethodContext; cust: Customer; date: Date; completedContext: JadeMethodContext; begin ... // One asynchronous method call is made context.invoke(cust, getHistory, date); ... // Wait for the asynchronous method call to complete completedContext := process.waitForMethods(context); write completedContext = context; // Outputs true ...
In the following diagram, the originating application makes two asynchronous method calls. The originating application then makes repeated calls to the waitForMethods method to receive information from the worker applications as the asynchronous method calls complete.
The first time around the loop, the waitForMethods method immediately returns context2, as it has already completed. The second time around the loop, it suspends processing until context1 is completed. The loop is then terminated, because the
The following code fragment shows the use of the waitForMethods method in this more-complicated scenario.
vars context1, context2: JadeMethodContext; cust1, cust2: Customer; date1, date2: Date; completedContext: JadeMethodContext; begin ... // Two asynchronous method calls are made context1.invoke(cust1, getHistory, date1); context2.invoke(cust2, getHistory, date2); ... completedContext := process.waitForMethods(context1, context2); // Loop through contexts as they finish while completedContext <> null do write completedContext; completedContext := process.waitForMethods(context1, context2); endwhile; ...