Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Inject a function (queue like)
Hi Gintaras, Hi all

I have a function built to process a file from Directory Opus (DO) file manager. The function is called from DO with the filename(s) as argument.

The function MyFunction begins with:

function str'&j
foreach _s j
...Do code with each file

1. How to "queue" a file if the function is already running. For instance I launched MyFunction with three files to process,
and I want to add one as the function is already busy.

2. How to launch several instances of MyFunction in the same time. At the time being, only one instance is allowed to run.

How the function is called from DO? If command line, what commandline used?
"C:\Program Files (x86)\Quick Macros\qm.exe" M "Fichiers_depuis_DO" A "{allfilepath$}" "1"
QM allows to run multiple function instances. Now I tested, it works with command line too.
Look in Properties -> Function properties.
Or maybe your function locks the file and DO then waits and does not run the function again.
Test multiple instances not from DO. For example create 2 shortcuts.
Also try to replace qm.exe to qmcl.exe. Maybe DO waits until QM process exits.
Ok for the function property, forgot that one.

What about implementing a queue? How to do it?
At the beginning insert


Then next thread will wait until previous thread leaves the locked code. Will be sequential execution instead of parallel.

But the number of threads is limited to 500 or 1000, don't remember. If will be many waiting threads, will need a queue, more work.
OK, sequential is good as long as I can add more than one file in successive calls.

Forget the queue if too much work, sequential is the same then for me.

Must I use lock- at the end of the function, and if so, where to put it exactly? Last line of function code?
With lock, files will be processed in random order. If need FIFO order, will need a queue.

lock- is not necessary.
FIFO is not needed, as I only need the job done, whatever the order of files processed.
Ok for lock not needed.

TY Gintaras.

BTW, you did not answered a word on this topic:

Guess you missed it....

Forum Jump:

Users browsing this thread: 1 Guest(s)