Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
0

[JSX]Multithreading

Explorer ,
Jul 26, 2012 Jul 26, 2012

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.

TOPICS
Scripting
3.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 27, 2012 Jul 27, 2012

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 30, 2012 Jul 30, 2012

Thnx for your reply..

I tried that, but no luck.

I have 2 files:

1. Download.jsx --->  downloads the data from server.

2. Application.jsx ----> main script that has the palette

I ran the "Download,jsx" script from "Application.jsx" script; and gave different targetengine to both.

The Indesign got hanged when i call "Download,jsx" for the time the image is downloaded.

But, i want that while the download process is done in background; user can work on the palette...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 30, 2012 Jul 30, 2012

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 30, 2012 Jul 30, 2012

Hey.. thanks for the prompt reply

Actually i was using  the same approach, but instead of python i was using "wget" and onIdle eventhandler to check wether the download is complete.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 30, 2012 Jul 30, 2012

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 30, 2012 Jul 30, 2012

I'm still working on it. Will reply you as soon as it gets done.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 30, 2012 Jul 30, 2012

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 30, 2012 Jul 30, 2012

I am in Windows environment and using "wget -b url -P pathToSave" .

And i am calling this in a .bat file.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 30, 2012 Jul 30, 2012

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 30, 2012 Jul 30, 2012

I am using the same version of wget, compiled for Windows. Yes, it goes to background doing its job and letting to work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 30, 2012 Jul 30, 2012

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 30, 2012 Jul 30, 2012

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 30, 2012 Jul 30, 2012
LATEST

I execute it from javascript as:


a=File("xyz.bat");

a.execute();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines