我正在尝试为matchcollection创建一个Parallel.Foreach循环。它就在我造的刮板里。我只需要知道在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();
}):我试过了:
Parallel.ForEach<MatchCollection>(m,match =>但是不走运!
提前感谢!:)
发布于 2012-05-29 02:39:01
这是因为Parallel.ForEach需要一个泛型IEnumerable,而MatchCollection只实现非泛型a。
试试这个:
Parallel.ForEach(
m.OfType<Match>(),
(match) =>
{
);https://stackoverflow.com/questions/10788972
复制相似问题