1
0
-1

hello community,

as far as you know is it possible for Uniface to run asyncronous instances of a proc at the same time? I have a proc that does something for, lets say, 600 records of a SQL table, and this work takes a lot of time: i was wondering if I can run simultaneously first 200 records in one thread, 200 in another, 200 in another one. At the same time.

I can do this by running 3 separate uniface.exe command lines but that's very tricky and can be done only in server behaviors with no interaction at all.

In my mind there should be something named like "CALL/ASYNC procname" that executes (with no return values?) some proc

Have you ever faced this thing, or there is something I don't know that can be used for this purpose?

thank you

  1. Gianni Sandigliano

    Ciao Simone,

    I suppose there is also an option using COM as an intermediate layer (but I never tried it!):
    a Uniface Client acting as a COM client activate/async a Uniface component on a Uniface session configured as a COM server.

    Gianni

CommentAdd your comment...

2 answers

  1.  
    1
    0
    -1

    Hi

    I do not know if with some 3GL magic it could be possible to open a new thread.

    The way of doing it, is using urouter. By asking it to run asynchronously a service so you are able to run several processes in parallel. But they are going to run in the server.

    Or using activate/async "OS".command("uniface command line")


    Also, it is possible to run locally several uniface.exe that work as daemons. Just a form waiting for Asynchronous messages. So, in your computer you have one main uniface.exe with the app, and several minimized uniface.exe doing nothing. Then, from the main uniface.exe can send a postmessages to these daemons to instruct them to do something. They will receive the message in Asynchronous Interrupt and run whatever you need.

    It is quite tricky as you need an urouter and also need that every "daemon" must register itself into urouter (using /dnp or $DNP). Urouter will keep a queue of messages for every registered client. It саn be a little odd to send a message to a server to be delivered to a process in my same computer. But think you are not limited to one computer: you can send these messages to three different unifaces in different machines.

    Hope it helps

    1. Simone Pecchenino

      Quite tricky to use the urouter but it indeed may be a workaround, thank you to point me there.

    CommentAdd your comment...
  2.  
    1
    0
    -1
    1. Simone Pecchenino

      If I use the activate/async switch, I have always a -161 error returned: "Illegal mixture of synchronous and asynchronous communication modes" even if I activate directly a form from a blank start up shell. Have you ever use that? How? thank you

    2. Daniel Iseli

      This will only work when executing the instance remotely (i.e. using URouter/UServer). "Locally" (i.e. in the same process) it's not possible to activate something asynchronously. There is a note in the doc for the /async qualifier:

      "Asynchronous operation invocation is only supported for components that are executed in a shared Uniface server or in an external middleware environment. Operations that are asynchronously invoked are not allowed to have OUT or INOUT parameters. They do not return a return value."

    3. Jason Huggins

      Yes, it works once configured. Two key points are to set the service property to asynchronous and use the services_exec section of the callers asn file to map the service to the relevant path  (see: https://documentation.uniface.com/10/uniface/configuration/reference/assignments/asn_fileSections/_SERVICES_EXEC_.htm?Highlight=services_exec). It is then typical to use postmessage and the recieveMessage trigger for inter process communication.


      Regards,

      Jason 


    4. Simone Pecchenino

      I am trying an easier approach: if I make an upper form with:


      filedump"C:\U9705\common\bin\uniface.exe APSname componentname","c:\test1.bat"

      spawn"c:\test1.bat"

      filedump"C:\U9705\common\bin\uniface.exe APSname componentname","c:\test1.bat"

      spawn"c:\test1.bat"


      I have asyncronously 2 new threads working on my componentname, obviously with no return values ( * ), weird that this can not be done somehow in the standard uniface proc


      ( * ) return value can be stored in a local file, or in the database

    5. Luis Vila

      Try better with 

      activate/async "OS".command("C:\U9705\common\bin\uniface.exe APSname componentname")

      Create a signature called OS for an operating system service with the Implementation Type set to Operating System Command. Then you can use it to run commands instead using spawn.

    6. Simone Pecchenino

      Thanks, it works. It's just like doing activate nameform asyncronously, should be implemented in uniface from my point of view

    CommentAdd your comment...