Page 1 of 1

TFindFile and WaitFor

PostPosted: August 28th, 2012, 3:49 am
by Kimbo
First, thanks for this awesome component!!!

I'm trying to perform several different task using one FindFile component. This FindFile created run-time. Let's see this execute pseudocode:

Code: Select all
for i := Low(Task) to High(Task) do begin
  FindFile.Threaded := True; { must }
  FindFile.Criteria...
  FindFile.OnFileMatch := ...
  ...
  FindFile.Execute;
end;


Since the FindFile are in threaded mode, so this "for" routine is not working properly. Is there any clue about WaitFor method that can be used so this kind of loop routine able to do its job, and without having to make the main thread (main form) hang?

Thanks in advance!

Re: TFindFile and WaitFor

PostPosted: August 28th, 2012, 10:56 am
by Kambiz
WaitFor blocks the calling thread anyway.
Instead of using a single instance of TFindFile to run the tasks one by one, I do suggest to create a new threaded instance of TFindFile for each task, so you can do all tasks simultaneously.