Skip to content

Instantly share code, notes, and snippets.

@explorer14
Created July 23, 2021 21:23
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 explorer14/94545dce40925247fda5fe1b48ab02be to your computer and use it in GitHub Desktop.
Save explorer14/94545dce40925247fda5fe1b48ab02be to your computer and use it in GitHub Desktop.
Parallel.For(0, 500,
async index =>
{
var product = new Product
{
Id = id,
Stock = index+1
};
using (var scope = new TransactionScope(
TransactionScopeAsyncFlowOption.Enabled))
{
await Save(product);
scope.Complete();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment