Skip to content

Instantly share code, notes, and snippets.

@shane-edmonds
Created December 15, 2013 00:00
Show Gist options
  • Save shane-edmonds/7966728 to your computer and use it in GitHub Desktop.
Save shane-edmonds/7966728 to your computer and use it in GitHub Desktop.
You can use the File.ReadLines Method to read the file line-by-line without loading the whole file into memory at once, and the Parallel.ForEach Method to process the lines in multiple threads in parallel.
Parallel.ForEach(File.ReadLines("file.txt"), (line, _, lineNumber) =>
{
// processing code here
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment