Run local procedure asynchronously (on Client Networking)

Posted by jadamski413@gmail.com on 21-Nov-2018 10:15

Can I invoke internal procedute asynchronously (without AppServer)?
for example I run procedure "test1.p":

test1.p:
---------------------------------------------------
def var procHand as handle.

run test2.p persistent set procHand.

for each Customer no-lock:
    if Customer.Balance > 1100 and Customer.Balance < 1200 then
    do:
        run doSomething in procHand asynchronous (input Customer.CustNum).
        display Customer.CustNum.
        display Customer.Name.
        display Customer.Phone.
    end.
    ...
end.
---------------------------------------------------


test2.p:
---------------------------------------------------

def var xTxt as char no-undo init ''.

xTxt = 'QWERTY'.

PROCEDURE doSomething:
    def input param pCustNum as integer.

    output to test.txt.
    find first Customer where Customer.CustNum = pCustNum no-lock no-wait no-error.
    if avail Customer then
    do:
        export CustNum Name Country State City Phone.
    end.
    output close.
    message 'Finish of asynchronous procedure' view-as alert-box info buttons OK.
END PROCEDURE.

---------------------------------------------------

This run properly, but unfortunatelly - synchronously.
Order of execution is:
1. run doSomething in procHand asynchronous (input Customer.CustNum).
2. All commands form procedure "doSomething"
3. display Customer.CustNum.
4. display Customer.Name.
5. display Customer.Phone.

I need to run this asynchronously so that the order of execution is:
1. run doSomething in procHand asynchronous (input Customer.CustNum).
2. display Customer.CustNum.
3. display Customer.Name.
4. display Customer.Phone.
and procedure "doSomething" was performed as a separate thread.

Is it possible?

Posted by Patrick Tingen on 21-Nov-2018 10:54

The short answer is 'no'. But you can - if you want to - initate a second session that communicates via sockets or database table to do extra work. That would not work well for the example you give here I guess, since you probably want to invoke several async processes.

Posted by Peter Judge on 21-Nov-2018 14:14

The only way to do that is to do it over an appserver.
 
RUN test2.p PERSISTENT SET procHand ON hdlAppServer.
 
 
You can also follow Patrick’s advice but currently the AVM only executes synchronously within a session (an AppServer call is a completely different session).
 

All Replies

Posted by Patrick Tingen on 21-Nov-2018 10:54

The short answer is 'no'. But you can - if you want to - initate a second session that communicates via sockets or database table to do extra work. That would not work well for the example you give here I guess, since you probably want to invoke several async processes.

Posted by Peter Judge on 21-Nov-2018 14:14

The only way to do that is to do it over an appserver.
 
RUN test2.p PERSISTENT SET procHand ON hdlAppServer.
 
 
You can also follow Patrick’s advice but currently the AVM only executes synchronously within a session (an AppServer call is a completely different session).
 

This thread is closed