Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
List opportunities = new List();
var sync = new object();
Parallel.ForEach(proxyOpportunities, (proxyOpportunity) =>
{
try
{
Opportunity convertedOpportunity = proxyOpportunity.ConvertToOpportunity();
lock (sync)
{
opportunities.Add(convertedOpportunity);
}
}
catch (Exception ex)
{
Opportunity failedOpportunity = new Opportunity()
{
ExcludeForImport = ExcludeReason.ImportFailed,
DocumentNumber = proxyOpportunity.With(x => x.DOC_ID)
};
lock (sync)
{
opportunities.Add(failedOpportunity);
}
LoggingWrapper logger = new LoggingWrapper();
logger.LogError(ex);
}
});
return opportunities;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment