I'm new to C#, but learning it. I figured out C# has many awesome methods such as Parallel.
So let's say my program has this method.
private void stackOverFlowExample()
{
List<string> testCompany = new List<string>();
List<People> testList = new List<People>();
testCompany.Add("Stack Over Flow 1");
testCompany.Add("Stack Over Flow 2");
testCompany.Add("Stack Over Flow 3");
...(1000 Times)...
Parallel.ForEach(testCompany, company =>
{
testList.Add(new People()
{
Name = value1, // Some values
Address = value2,
Phone = value3,
Company = company
});
});
}
So does above code have thread related problems? And is there any book or guide related to thread problems solving that you can recommend?