File handling in a threadpool

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all, I have a Windows service that uses a thread pool and a file watcher.
Everything works well enough except for the problem of a given file being
opened by more than one thread.

What is a good way to make sure that once a given file is opened by a thread
no other threads will open it for processing?
 
Keep a list of files currently being processed as a thread-safe hashtable.
Each thread will be updating the list with the file it is working on.
Before a thread tries to open a new file, it must check the file is not on
the list.
 
Back
Top