DEFINE VARIABLE hSrv AS HANDLE NO-UNDO.
DEFINE VARIABLE bool AS LOGICAL NO-UNDO. CREATE SERVER hSrv. hSrv:CONNECT("-URL AppServerDC://hostName/svc"). bool = hSrv:CANCEL-REQUESTS-AFTER(30). RUN foo.p ON SERVER hSrv ASYNCHRONOUS ("Hello World"). WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW. |
/* srvrNested3.p */
DEFINE INPUT-OUTPUT PARAMETER p1 AS CHARACTER NO-UNDO. DEFINE VARIABLE srvrTimeLimit AS INTEGER NO-UNDO INITIAL 10. DEFINE VARIABLE spinLimit AS INT64 NO-UNDO INITIAL 15000. p1 = FILL("Y", 30). /* 30 "Y" characters will be sent to the client */ DO STOP-AFTER srvrTimeLimit: RUN spinHere (spinLimit). END. RETURN "30 Ys". PROCEDURE spinHere: DEFINE INPUT PARAMETER spinLimit AS INT64 NO-UNDO. DEFINE VARIABLE loopFlag AS LOGICAL NO-UNDO. DEFINE VARIABLE endTime AS INT64 NO-UNDO. ASSIGN loopFlag = TRUE endTime = ETIME(FALSE) + spinLimit. DO WHILE loopFlag: IF (ETIME(FALSE) > endTime) THEN loopFlag = FALSE. END. END PROCEDURE. |
/* clntNested4.p */
DEFINE BUTTON send-button LABEL "SEND". DEFINE BUTTON close-button LABEL "CLOSE". DEFINE VARIABLE ah AS HANDLE NO-UNDO. DEFINE VARIABLE cstr AS CHARACTER NO-UNDO. DEFINE VARIABLE rcvcnt AS INTEGER NO-UNDO. DEFINE VARIABLE sh AS HANDLE NO-UNDO. DEFINE VARIABLE S1 AS CHARACTER NO-UNDO FORMAT "X(30)". DEFINE VARIABLE S2 AS CHARACTER NO-UNDO FORMAT "X(30)". DEFINE VARIABLE xmtcnt AS INTEGER NO-UNDO. /* =============================================================== */ FORM send-button close-button WITH FRAME buttonFrame. DEFINE FRAME foo S1 AT 1 WITH NO-LABELS. DEFINE FRAME bar S2 AT 1 WITH NO-LABELS. /* =============================================================== */ ON CHOOSE OF send-button DO: RUN runRemoteProc. S1 = "Ran proc(" + STRING(xmtcnt) + ")". DISPLAY S1 WITH FRAME foo 1 DOWN. HIDE FRAME bar. END. ON CHOOSE OF close-button DO: sh:DISCONNECT(). DELETE OBJECT sh. QUIT. END. ON WINDOW-CLOSE OF CURRENT-WINDOW DO: sh:DISCONNECT(). DELETE OBJECT sh. QUIT. END. ENABLE send-button close-button WITH FRAME buttonFrame. CREATE SERVER sh. cstr = "-URL AppServerDC://hostname:portnum/svc". sh:CONNECT(cstr). WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW OR CHOOSE OF close-button. sh:DISCONNECT(). DELETE OBJECT sh. /* =============================================================== */ PROCEDURE runRemoteProc: DEFINE VARIABLE ix AS CHARACTER NO-UNDO. ASSIGN xmtcnt = xmtcnt + 1 ix = FILL("X", 30). sh:CANCEL-REQUESTS-AFTER(10). DO STOP-AFTER 5: RUN srvrNested3.p ON SERVER sh ASYNCHRONOUS SET ah EVENT-PROCEDURE "remoteProcHandler" IN THIS-PROCEDURE (INPUT-OUTPUT ix). END. END PROCEDURE. /* =============================================================== */ PROCEDURE remoteProcHandler: DEFINE INPUT PARAMETER ix AS CHARACTER NO-UNDO. ASSIGN rcvcnt = rcvcnt + 1 S2 = "remoteProcHandler(" + STRING(rcvcnt) S2 = S2 + IF (SELF:STOP) THEN ") STOPPED" ELSE IF (SELF:CANCELLED) THEN ") CANCELLED" ELSE ") FINISHED". DISPLAY S2 WITH FRAME bar 1 DOWN. DELETE OBJECT SELF. END PROCEDURE. |