The IDL_IDLBridge object is a useful tool for executing tasks in the background, but it can be cumbersome. To simplify using it, I developed the program thread.pro which allows you execute any IDL procedure in the background. The program works like IDL’s call_procedure whereby you pass the procedure name and its corresponding arguments and keywords:
The program takes care of the internal passing of arguments and keywords to the IDL_IDLBridge object. It is limited to handling up to 10 input arguments and any number of arbitrary keywords. The arguments and keywords can also act as return outputs, but it is subject to the limitation that only scalar or array variables of numeric or string type can be transferred. Structures, pointers, and object references cannot be transferred between processes using the IDL_IDLBridge object.
Here is an example of calling it to download multiple files from a remote server using the program webcopy.pro.
Calling a function in a thread is a little trickier, but can be performed using the special keyword function_output to return the output of the function as follows:
Here is an example calling the congrid function on an image array:
IDL> thread,'congrid',findgen(100,100),1024,1024,function_output=out % THREAD_CALLBACK: Completed. IDL> help,out OUT FLOAT = Array[1024, 1024]
Note that while the thread is processing, the function output variable will be undefined. Once the thread callback function signals that the processing has completed, the output result will be returned.
By default, the thread procedure will only run a single instance of the IDL_IDLBRIDGE. Consequently, if you try calling thread again you will get a message that the current thread is busy. If you wish to run multiple threads, you can use the keyword /new_thread which will start a new separate thread process.