There is a system who put files on a folder on a disk.
I'm writing an executable (c#) which take these files and send them into a database.
My executable can be started multiples times in the same time (in parallel) and I have a multithread problem with processing files.
Example:
- There are 50 files in folder.
- The executable 1 takes 10 files to process.
- The executable 2 takes 10 files to process.
My questions are:
- How can I be sure that my executable 2 don't take executable 1 files?
- How can I lock the 10 files from executable 1?
- How to make this process thread safe?