I’m trying to create a Parallel.Foreach loop for matchcollection.
It’s in a scraper I built.
I just need to know what to put in the Parallel.Foreach
MatchCollection m = Regex.Matches(htmlcon, matchlink, RegexOptions.Singleline);
Parallel.ForEach(WHAT DO I PUT HERE? =>
{
Get(match.Groups[1].Value, false);
Match fname = Regex.Match(htmlcon, @"<span class=""given-name"(.*?)</span>", RegexOptions.Singleline);
Match lname = Regex.Match(htmlcon, @"span class=""family-name"">(.*?)</span>", RegexOptions.Singleline);
firstname = fname.Groups[1].Value;
lastname = lname.Groups[1].Value;
sw.WriteLine(firstname + "," + lastname);
sw.Flush();
}):
I tried:
Parallel.ForEach<MatchCollection>(m,match =>
but no luck!
Thanks in advance! 🙂
That’s because
Parallel.ForEachis expecting a genericIEnumerableandMatchCollectiononly implements the non generic one.Try this: