Processing file with multiple threads
I was working on a project where I needed to process an input file and perform an action for each line. The action was a network call that was taking a few seconds to update. At low numbers of records in the file this normally wouldn't be a big deal but I was looking at 10's of thousands of lines and so needed something that could process the lines in parallel. Since the processing of the lines was being performed by I could just spin up some threads to send the lines to the network service.
Since this was a long running overall process, I also wanted to have some tracking. The tracking should indicate how quickly lines are getting process and include some estimate of how long it would take to complete the processing of the file.
Attached you'll find the project that has a Console project with a sample file for processing and a simulated long task using Thread.Sleep.