Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am new to C# and working on a project. The project reads the multiple .csv files (in a folder) and parse them and show the results in the windows application. Although it processes the files very slow. So i had to ask can i use multithreading for reading files Or is there any other technique which i can implement to make the reading and parsing the files and showing the results fast?
Thanks

What I have tried:

Using the simple methods to reading and parsing files
Posted
Updated 8-Nov-19 3:43am

Multithreading is not guaranteed to make a great difference, and will depend on what your code is doing. The first thing to look at is where the slow processing actually occurs. Is the delay due to the speed of getting the data off disk, or in processing it once it's in memory?
 
Share this answer
 
Comments
Member 14646256 11-Nov-19 13:09pm    
If the delay is due to the processing once it is in memory, is there any other solution which you can recommend?
The program reads the csv file, parse it and show details, and then it does same for next file, in this way it reads all files in the folder. So is it also possible that i first read all files, parse and then show details of all at once? Is it possible?
Richard MacCutchan 12-Nov-19 3:06am    
You cannot work on a solution until you know where the delay is. Run some timing tests to find out where the program spends most time. Only then can you start working on improving performance.
I would recommend using Task.Factory, see example here: Whats the best way of asynchronous parsing a CSV file in c# - Stack Overflow[^]
 
Share this answer
 
File size, the number of files and what you're doing to the data are all primary factors. Only you can determine the sweet spot, or if you should even implement any kind of threading.
 
Share this answer
 

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