Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
If you run your palette code in different targetengine the user shouldn't be blocked from main InDesign UI.
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
I'm still working on it. Will reply you as soon as it gets done.
Copy link to clipboard
Copied
How do you call `wget`? (`wget URL` vs `wget URL&`)
Copy link to clipboard
Copied
I am in Windows environment and using "wget -b url -P pathToSave" .
And i am calling this in a .bat file.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
I am using the same version of wget, compiled for Windows. Yes, it goes to background doing its job and letting to work.
Copy link to clipboard
Copied
I'm surprised it doesn't do the same when run from InDesign
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
I execute it from javascript as:
a=File("xyz.bat");
a.execute();
Find more inspiration, events, and resources on the new Adobe Community
Explore Now