Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi to all...

my requirement is that i have a Queue of string in which 10 files are there. and i have to copy the files in another location in another thread in for each loop.

But my problem is that when this process is doing there work i want to add some more files in the same queue so that after finishing the 10 files another file will start copy automatically.
Posted
Comments
Sergey Alexandrovich Kryukov 10-Jul-12 3:39am    
Why 10?
--SA
Trak4Net 13-Jul-12 1:39am    
Is your requirement that the 10 files are to be grouped together or is each individual file processed as its own and you just want to keep processing while the queue has items and be able to continue to add to the queue?

1 solution

In this case, you will have to keep the "Copier Thread" running all the time. Put it on hold when all files in the list are copied. Use
C#
System.Threading.AutoResetEvent.WaitOne();
for that in the Copier Thread.

In another thread, you can add a new path to your list and call
C#
System.Threading.AutoResetEvent.Set();
. That will trigger the Copier Thread to resume until it has, again, reached the end of the list and enters the waiting state.

MSDN[^] tells about the details.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900