title: Read and process files in parallel C#
body: <p>I have very big files that I have to read and process. Can this be done in parallel using Threading?</p>
  
  <p>Here is a bit of code that I've done. But it doesen't seem to get a shorter execution time the reading and processing the files one after the other.</p>
  
  <pre><code>String[] files = openFileDialog1.FileNames;
  
  Parallel.ForEach(files, f =&gt;
  {
      readTraceFile(f);
  });        
  
  private void readTraceFile(String file)
  {
      StreamReader reader = new StreamReader(file);
      String line;
  
      while ((line = reader.ReadLine()) != null)
      {
          String pattern = "\\s{4,}";
  
          foreach (String trace in Regex.Split(line, pattern))
          {
              if (trace != String.Empty)
              {
                  String[] details = Regex.Split(trace, "\\s+");
  
                  Instruction instruction = new Instruction(details[0],
                      int.Parse(details[1]),
                      int.Parse(details[2]));
                  Console.WriteLine("computing...");
                  instructions.Add(instruction);
              }
          }
      }
  }
  </code></pre>