Posts: 795
	Threads: 136
	Joined: Feb 2009
	
	
 
	
	
		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.
Thanks
	
	
	
	
	
 
 
	
	
	
		
	Posts: 12,239
	Threads: 144
	Joined: Dec 2002
	
	
 
	
	
		How the function is called from DO? If command line, what commandline used?
	
	
	
	
	
 
 
	
	
	
		
	Posts: 795
	Threads: 136
	Joined: Feb 2009
	
	
 
	
	
		"C:\Program Files (x86)\Quick Macros\qm.exe" M "Fichiers_depuis_DO" A "{allfilepath$}" "1"
	
	
	
	
	
 
 
	
	
	
		
	Posts: 12,239
	Threads: 144
	Joined: Dec 2002
	
	
 
	
	
		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.
	
	
	
	
	
 
 
	
	
	
		
	Posts: 795
	Threads: 136
	Joined: Feb 2009
	
	
 
	
	
		Ok for the function property, forgot that one.
What about implementing a queue? How to do it?
	
	
	
	
	
 
 
	
	
	
		
	Posts: 12,239
	Threads: 144
	Joined: Dec 2002
	
	
 
	
	
		At the beginning insert
lock
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.
	
	
	
	
	
 
 
	
	
	
		
	Posts: 795
	Threads: 136
	Joined: Feb 2009
	
	
 
	
	
		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?
	
	
	
	
	
 
 
	
	
	
		
	Posts: 12,239
	Threads: 144
	Joined: Dec 2002
	
	
 
	
	
		With lock, files will be processed in random order. If need FIFO order, will need a queue.
lock- is not necessary.
	
	
	
	
	
 
 
	
	
	
		
	Posts: 795
	Threads: 136
	Joined: Feb 2009
	
	
 
	
	
		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: 
http://www.quickmacros.com/forum/showthr...p?tid=4971
Guess you missed it....