For each file I copy I am creating and then freeing a TThread object.
My problem is that after around 30 files, the next thread creation never
starts execution of the copy code.
Any ideas, or examples of how this should be done ?
Philip
Philip
Philip B Cook <phili...@smoogro.freeserve.co.uk> wrote in message
news:399e6360_1@dnews...
Bad approach, in my opinion. You should have a single thread and a queue of
copy requests it works on (a TThreadlist of task objects, for instance). If
you create a thread for each copy operation you end up with several running in
parallel. Since the actual disk access has to be serialized by the OS anyway
you will rapidly reach a point where adding more threads makes the overall
process slower, due to the management overhead of threads. If you run on
Win9x, for example, a process should not create more than 16 threads and even
that only if most of them will be blocked most of the time.
Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Philip,
I have no idea on what your problem might be. Some error in the
code probably. But I think you can do the same without threads.
Just recently I had a complex 4 thread design which ended in a
deadlock after several minutes of processing. Took me days to
develop this. Only to discover that it runs just fine without
any additional threads.
Have developed a class that can move files, folders and whole
directory trees (TFileOperation). The copy operations still have
to be added but since I don't use them yet... You get an event
before and after each file or folder is moved and an additional
event if an error occurred with information why this did not work.
All without threads. Contact me if you want to know more.
Or you simply use ShFileOperation and you get the windows copy/
move window with flying files and windows worries about every-
thing (I needed more details so this was not for me).
Regards,
WL
Ahha... that bugbear of stread writers: the timing window.
<blatant plug> Why not refresh your mind with a copy of
http://www.pergolesi.demon.co.uk/prog/threads/ToC.html
</blatant plug>
There's a demo in there that calculates CRC's for a directory which
might be of interest.
MCH.
--
Martin Harvey. mar...@pergolesi.demon.co.uk
http://www.pergolesi.demon.co.uk
ICQ: 37298917