[progress Communities] [progress Openedge Abl] Forum Post: Re: Asynchronous Appserver Call...

  • Thread starter Thread starter jbijker
  • Start date Start date
Status
Not open for further replies.
J

jbijker

Guest
Hi Peter When doing an asynchronous call (applies to appserver & web service call) you need to save the asynchronous request handle and specify an event procedure, something like: RUN MyProcedure IN ServerHandle ASYNCHRONOUS SET hRequestHandle EVENT-PROCEDURE MyEventProcedure IN TARGET-PROCEDURE (...all the parameters you need, input & output - although output will not be set at this stage...) NO-ERROR. Do your normal error checking here to catch any errors while trying to make the call. Now for the event procedure. In this example we expect it to return a character variable back, change it to whatever you need. You don't need to specify any input parameters. When it runs this procedure ERROR-STATUS:ERROR and RETURN-VALUE will be set, so we need to preserve it in global variables which will be used later. PROCEDURE MyEventProcedure: DEFINE INPUT PARAMETER ipcResult AS CHARACTER NO-UNDO. glErrorStatus = ERROR-STATUS:ERROR. gcReturnValue = RETURN-VALUE(1). gcResult = ipcResult. END PROCEDURE. Then you need to wait for this request to complete. Below I simply wait (plus timeout if it exceeds a specific time). Whenever the event procedure was run DO ON ERROR UNDO, THROW: ASSIGN giEtimeNow = ETIME. DO WHILE TRUE: PROCESS EVENTS. IF hRequestHandle:COMPLETE THEN LEAVE. IF ETIME > giEtimeNow + giAsyncTimeout THEN DO: hRequestHandle:CANCEL-REQUESTS(). PROCESS EVENTS. RETURN ERROR "Asynchronous request timeout.". END. END. /* when it hits this it means the procedure completed and we should be able to use our global variables to see if it completed successfully */ IF glErrorStatus THEN .. do your error handling here ... FINALLY: IF VALID-HANDLE(hRequestHandle) THEN DELETE OBJECT hRequestHandle. END FINALLY. END. Hope this helps. Regards Johan

Continue reading...
 
Status
Not open for further replies.
Back
Top