Skip navigation
Currently Being Moderated

[JSX]Multithreading

Jul 27, 2012 2:39 AM

How can we implement multithreading in indesign javascript?

 

In my script, i have a palette in which has images that are downloaded from the server. So, i want to seperate the UI with the dowloading process such that while the images are being downloaded in background, the user can perform actions with the palette. Else, the indesign will be hanged for the time it takes to download all the images.

 
Replies
  • Currently Being Moderated
    Jul 27, 2012 8:39 AM   in reply to sahil.dillinger

    If you run your palette code in different targetengine the user shouldn't be blocked from main InDesign UI.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 30, 2012 1:56 AM   in reply to sahil.dillinger

    I'm afraid I can't help without seeing the scripts.

     

    I had problems with the asynchronous resource downloads some time ago and

    I decided not to use javascript for it. So my "Application.jsx" launched

    external "Download.py" (Python) in the background, which started the download

    without blocking InDesign at all.

     

    The downside of it is that you may have hard time showing the download progress

    to the user. If you want this you can have the external downloader write some

    this-is-where-I-am kind of message to a temp file and have your palette

    periodically look for its contents (with onIdle event) and display it as progress

    message or construct some widget based on it. I never felt the need for it though,

    as I have all my scripts write to a log so I can see it there. (less eye candy

    but equally functional).

     

    Harder part was to say goodbye to my pure javascript download code that

    I crafted on top of the Socket object. But we have to accept that extendscript

    is not omnipotent and when there is better tool for the job, I won't hesitate

    to use it.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 30, 2012 3:55 AM   in reply to sahil.dillinger

    This may be a potshot in the dark, but how does it affect your issues with locked UI when you won't register your onIdle event?

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 30, 2012 4:08 AM   in reply to sahil.dillinger

    How do you call `wget`? (`wget URL` vs `wget URL&`)

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 30, 2012 5:56 AM   in reply to sahil.dillinger

    What happens when you execute "wget -b url -P pathToSave" from the command line? Do you have to watch the download process before you allowed to enter another command or  does it go to background, doing its job and letting to work? '-background' option seems to do the trick on unix version of wget

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 30, 2012 6:23 AM   in reply to sahil.dillinger

    I'm surprised it doesn't do the same when run from InDesign

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 30, 2012 6:33 AM   in reply to sahil.dillinger

    sahil.dillinger wrote:

     

    And i am calling this in a .bat file.

    By "how do you call" I meant how do you execute it from javascript.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points