• Looking for async I/O method between GUIs on Win32

    From $Bill@21:1/5 to All on Sat Feb 13 04:26:58 2021
    I have a GUI that I use to acquire URLs that point to web files.
    I want to keep the GUI active while the file is being transferred to disk and I have a second GUI that given a URL and disk path will handle the transfer.
    I may wish to run multiple of the 2nd GUI (haven't decided yet), but want to allow
    for it.
    I need 1) a method to run the 2 or more tasks asynchronously, 2) a way to determine
    the return status to the 1st GUI. There are a number of ways I could do this, but
    I'm looking for something that will blend into the event driven GUI mechanism.

    Back in my mini-computer days, I would have forked off the 2nd GUI and used a shared
    memory region to pass the status back on completion and a semaphore to handle any
    simultaneous memory access. But digging into Win32 internals from Perl complicates
    things a bit. Has anyone got an elegant solution to this besides just forking off
    a process and polling a pipe/file to wait for the response or using a socket to communicate (seems overly complicated) status back. I also was thinking about using
    threads in a single task (not sure how GUI events fit into threads).

    So any elegant suggestions on the high level method of GUI communication between two
    GUI tasks would be appreciated - hopefully someone who has done it successfully. ;)

    PS: I'm using regular Perl Tk for the GUI.

    TIA, Bill

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From star mister@21:1/5 to All on Sat Feb 13 17:11:02 2021
    Perhaps the module Promises could be a good option:

    https://metacpan.org/pod/Promises

    Their example looks somewhat like what you hope to do.
    You would also need modules AnyEvent::HTTP and JSON::XS

    And there is running parallel operations with fork:

    https://metacpan.org/pod/Parallel::ForkManager

    Tk has an event loop you can tie into if the above seems complex:

    https://tkdocs.com/tutorial/eventloop.html

    https://www.foo.be/docs/tpj/issues/vol1_3/tpj0103-0006.html

    On Saturday, February 13, 2021 at 6:27:03 AM UTC-6, $Bill wrote:
    I have a GUI that I use to acquire URLs that point to web files.
    I want to keep the GUI active while the file is being transferred to disk and I
    have a second GUI that given a URL and disk path will handle the transfer.
    I may wish to run multiple of the 2nd GUI (haven't decided yet), but want to allow
    for it.
    I need 1) a method to run the 2 or more tasks asynchronously, 2) a way to determine
    the return status to the 1st GUI. There are a number of ways I could do this, but
    I'm looking for something that will blend into the event driven GUI mechanism.

    Back in my mini-computer days, I would have forked off the 2nd GUI and used a shared
    memory region to pass the status back on completion and a semaphore to handle any
    simultaneous memory access. But digging into Win32 internals from Perl complicates
    things a bit. Has anyone got an elegant solution to this besides just forking off
    a process and polling a pipe/file to wait for the response or using a socket to
    communicate (seems overly complicated) status back. I also was thinking about using
    threads in a single task (not sure how GUI events fit into threads).

    So any elegant suggestions on the high level method of GUI communication between two
    GUI tasks would be appreciated - hopefully someone who has done it successfully. ;)

    PS: I'm using regular Perl Tk for the GUI.

    TIA, Bill

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)