Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hbulens/baf126ee106fc67b1e68557b0dd5a885 to your computer and use it in GitHub Desktop.
Save hbulens/baf126ee106fc67b1e68557b0dd5a885 to your computer and use it in GitHub Desktop.
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