Cor,
I am quiet sure that using threads for diskcopying is useless.
I'm suspect, for you, you are correct! :-|
you even have even to check in a strange way that you are not using twice
the same filename in multiple
Which is what the Thread Safe Queue is for. Here I am referring to a
System.Collections.Queue object. Then using either Queue.Synchronized to
create a thread safe Queue or encapsulate the Queue in your own class with
SyncLock statements to make it Thread Safe.
Seeing as a Queue is a First In First Out (FIFO) construct you would put all
the copy requests (an object with source name & destination name properties)
into the Queue. The workers would then read a request & process the copy.
the change that it will blow up your program because you cannot control a
part of this process.
My change (using a Thread Safe Queue) is a standard pattern for
multi-threading, its the pattern that ThreadPool is based on (as suggested
by the method ThreadPool.QueueUserWorkItem)
Asynchronous File I/O is a standard pattern within the Framework.
http://msdn.microsoft.com/library/d...n-us/cpguide/html/cpconasynchronousfileio.asp
I hope you realize my real suggestion to Luis was to limit the number of
requests, I was then offering alternatives that he may not have considered.
I do agree that one needs to be more careful writing multi-threaded
applications or not using Multi-threading, however as you reread the Luis's
original question, you will find he is already using Multi-threading!
Hope this helps
Jay