G
geertjeguns@hotmail.com
Guest
Hello everyone, I'm trying to launch 2 asynchronous programs on a server. Each program will execute a query on a different DB and at the end return the results. Both programs have to be executed within a predefined time-frame. After that time, the result will not be taken into account. I'm still having some problems with the wait-for part. For the moment I'm waiting on my second program. But how can I wait on both programs and still cancel its execution when the time has passed? Here is what I have so far: Main program: DEFINE VARIABLE hAppServer AS HANDLE NO-UNDO. DEFINE VARIABLE hAppServer2 AS HANDLE NO-UNDO. DEFINE VARIABLE hRequest AS HANDLE NO-UNDO. DEFINE VARIABLE hRequest2 AS HANDLE NO-UNDO. DEFINE VARIABLE wlOk AS LOGICAL NO-UNDO. DEFINE VARIABLE wiTimeOut AS INTEGER NO-UNDO INIT 10000. CREATE SERVER hAppserver. hAppserver:CONNECT("-AppService assv1 -H localhost","geegun","geegun"). CREATE SERVER hAppserver2. hAppserver2:CONNECT("-AppService assv1 -H localhost","geegun","geegun"). /* both procedures have to run asynchronous to save time */ RUN proctwo.p ON SERVER hAppserver ASYNCHRONOUS SET hRequest EVENT-PROCEDURE "procEnd" IN THIS-PROCEDURE (INPUT wiTimeOut, OUTPUT wcText AS CHARACTER, OUTPUT wcStatus AS CHARACTER). RUN procthree.p ON SERVER hAppserver2 ASYNCHRONOUS SET hRequest2 EVENT-PROCEDURE "procEnd" IN THIS-PROCEDURE (INPUT wiTimeOut, OUTPUT wcText AS CHARACTER, OUTPUT wcStatus AS CHARACTER). MESSAGE "one" VIEW-AS ALERT-BOX. ETIME(TRUE). /* We wait for a certain time to give the asynchronous programs the time to gather their data */ DO STOP-AFTER wiTimeOut ON STOP UNDO : WAIT-FOR PROCEDURE-COMPLETE OF hRequest2. END. /* Here comes the code to put all the data into a browser on the screen */ FINALLY: hAppServer
ISCONNECT(). DELETE OBJECT hAppServer. hAppserver2
ISCONNECT(). DELETE OBJECT hAppserver2. END. PROCEDURE procEnd: DEFINE INPUT PARAMETER ipcText AS CHARACTER NO-UNDO. DEFINE INPUT PARAMETER ipcStatus AS CHARACTER NO-UNDO. IF ipcStatus = "COMPLETED" THEN MESSAGE ipcText VIEW-AS ALERT-BOX. END PROCEDURE. Program 1 (proctwo.p): DEFINE INPUT PARAMETER wiTimeOut AS HANDLE NO-UNDO. DEFINE OUTPUT PARAMETER wcText AS CHARACTER NO-UNDO. DEFINE OUTPUT PARAMETER wcStatus AS CHARACTER NO-UNDO. DEFINE VARIABLE wii AS INTEGER NO-UNDO. DEFINE VARIABLE wicount AS INTEGER NO-UNDO. DO STOP-AFTER wiTimeOut ON STOP UNDO, RETURN ERROR "ERROR" : /* Enabling this DO will make this result fail to have a result */ /* DO wii = 1 TO 10: */ FOR EACH signcli NO-LOCK: wicount = wicount + 1. END. /* END. */ ASSIGN wcText = "two" wcStatus = "COMPLETED" . END. Program 2 (progthree.p): DEFINE INPUT PARAMETER wiTimeOut AS HANDLE NO-UNDO. DEFINE OUTPUT PARAMETER wcText AS CHARACTER NO-UNDO. DEFINE OUTPUT PARAMETER wcStatus AS CHARACTER NO-UNDO. DEFINE VARIABLE wii AS INTEGER NO-UNDO. DEFINE VARIABLE wicount AS INTEGER NO-UNDO. DO STOP-AFTER wiTimeOut ON STOP UNDO, RETURN ERROR "ERROR" : /* Enabling this DO will make this result fail to have a result */ /* DO wii = 1 TO 10: */ FOR EACH signcli NO-LOCK: wicount = wicount + 1. END. /* END. */ ASSIGN wcText = "three" wcStatus = "COMPLETED" . END. Kind regards, Geert Guns
Continue reading...
Continue reading...