C# Multithreading File IO (Reading)

Posted by washtik on Stack Overflow See other posts from Stack Overflow or by washtik
Published on 2010-04-20T07:51:25Z Indexed on 2010/04/20 7:53 UTC
Read the original article Hit count: 517

We have a situation where our application needs to process a series of files and rather than perform this function synchronously, we would like to employ multi-threading to have the workload split amongst different threads.

Each item of work is:
1. Open a file for read only
2. Process the data in the file
3. Write the processed data to a Dictionary

We would like to perform each file's work on a new thread? Is this possible and should be we better to use the ThreadPool or spawn new threads keeping in mind that each item of "work" only takes 30ms however its possible that hundreds of files will need to be processed.

Any ideas to make this more efficient is appreciated.

© Stack Overflow or respective owner

Related posts about c#

Related posts about file-io