Skip to content
Discussion options

You must be logged in to vote

As @AlexDaines said the Parallel.For doesn't await the Action passed in so the 10000 iterations fire off immediately because as far Parallel.For is concerned the Action is over once you hit your first await call and then starts another one.

I think all you have to do is change the Parallel.For to Parallel.ForEachAsync. Don't forget to await the Parallel.ForEachAsync call.

        await Parallel.ForEachAsync(
            Enumerable.Range(0, 10_000),
            new ParallelOptions
            {
                MaxDegreeOfParallelism = 8
            },
            async (i, ct) =>
            {
                var getRequest = new GetItemRequest
                {
                    TableNa…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by dscpinheiro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants