Matchcollection Parallel.Foreach

c#, multithreading, parallel-processing

Solution

That's because `Parallel.ForEach` is expecting a generic `IEnumerable` and `MatchCollection` only implements the non generic one.

Try this:

Parallel.ForEach(
    m.OfType<Match>(),
    (match) =>
    {
    );

Problem

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! :)

Original source