I would like to use the new Parallel.ForEach function to loop through a datatable and perform actions on each row. I am trying to convert the code below:
foreach(DataRow drow in dt.Rows)
{
...
Do Stuff
...
}
To this code:
System.Threading.Tasks.Parallel.ForEach(dt.Rows, drow =>
{
...
Do Stuff
...
});
When I run the new code I get the error:
The type arguments for method 'System.Threading.Tasks.Parallel.ForEach(System.Collections.Generic.IEnumerable, System.Action)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
What is the correct syntax for this?