How can I convert this foreach code to Parallel.ForEach?

I am a bit of confused about Parallel.ForEach.
What is Parallel.ForEach and what does it exactly do?
Please don’t reference any MSDN link.

Here’s a simple example :

string[] lines = File.ReadAllLines(txtProxyListPath.Text);
List<string> list_lines = new List<string>(lines);

foreach (string line in list_lines)
{
    //My Stuff
}

How can I rewrite this example with Parallel.ForEach?

6 Answers
6

Leave a Comment