There's a productivity tool being used in our department. Basically what it does is extract data from multiple excel files, make some data transformation, and export the corresponding output as text files.
I managed to have the copy of the source code and investigated how the text files are being generated. I found out that the developer created multiple BackgroundWorkers, one for each report that will be generated. It looks like this:
bgWorkerGenerateTextReport_1.RunWorkerAsync(); // inside the doWork method, it calls the actual method that generates the text file
bgWorkerGenerateTextReport_2.RunWorkerAsync();
bgWorkerGenerateTextReport_3.RunWorkerAsync();
bgWorkerGenerateTextReport_4.RunWorkerAsync();
bgWorkerGenerateTextReport_5.RunWorkerAsync();
bgWorkerGenerateTextReport_6.RunWorkerAsync();
// more bgWorkers follow...
At the completion of each backgroundWorker, it makes the linkLabel visible that corresponds to the location of the text file so the user can click it.
Some of the generated text files are very large (some contains almost a million rows and around 200 columns). I wanted to improve the tool since I have access to the source code.
First, I want to know what would be the better way to generate the text reports in parallel compared to declaring multiple backgroundWorkers. I know the original approach works, but I'm wondering what would be the more elegant and proper approach.
I tried directly calling the methods the generate the different reports but the UI became unresponsive while processing the files.