我怎样才能立即摆脱以下 Parallel.ForEach 循环...
Parallel.ForEach(
webnode.ChildNodes.OfType<XmlNode>(),
(node,loopState) =>
{
if(threadCommand!=null && threadCommand.CurrentSubIndicator.StopSignaled)
loopState.Stop();
string title = node.Attributes["Title"].Value;
string url = node.Attributes["Url"].Value;
if (!string.IsNullOrEmpty(specificItemUrl) &&
(!url.Equals(specificItemUrl)))
return;
Site partialSubSite = new WSS(site, Guid.Empty, title, url, "", null, null);
try
{
GetSite(partialSubSite, lite, readNavigation);
}
catch (Exception ex)
{
LogERError("Failed to fully read sub-site: {0}", url, ex);
partialSubSite.Guid = Constants.BadItemId;
}
});
if (threadCommand!=null && threadCommand.CurrentSubIndicator.StopSignaled)
一旦我检查条件并发现为真,我想退出所有线程以停止执行
。我怎样才能做到这一点?