Click here to Skip to main content
15,868,419 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

How to restrict the randomly loop running in Parallel.For using vb.net?
Is any option is available to run '0'-th index to 'N'-th index sequentially.

Example:
Array List having 10 items, its total count as 10.
and Using Parallel.for loop execute one by one random wise,

Performance oriented this feature is very good, so I want overcome normal for loop to Parallel.For loop.

Actual Parallel.For loop output is:
C#
Output: 1,5,2,7,0,3,8,4,9,6.


I want to execute value one by one like normal For loop.
C#
Output: 0,1,2,3,4,5,6,7,8,9.

If available, then which function used to handle this.

.
Posted
Updated 20-Oct-14 2:46am
v5

1 solution

What are you saying is that the second iteration of the loop can start parallel with the first but it have to wait to finish for the first...
By design parallel loops define that the order of the output has no significance...So what you ask for is not possible...
Also remember that parallel no always perform better than sequential...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900