Difference between For & Parallel.For in c# RRS feed

  • Question

  • 1) what is Parallel.For loop ?

    2) what is the usage of Parallel.For loop ?

    3) when People use Parallel.For instead of normal for loop?

    4) how Parallel.For loop is different from normal for loop?

    suppose i am read a data table value in for loop like

    for(int x=0; x<=mydatatable.rows.count-1;x++)



    in what kind of situation one should use Parallel.For loop to read data from datatable ?

    looking for good discussion the difference between for & Parallel.For loop ? and their usage difference. please explain all my points with sample code & example . thanks

    Saturday, May 18, 2013 7:15 PM



    For and Foreach loops are common and tremendously powerful constructs. Many times when using these constructs,each iteration depends on a calculation or action in the previous iteration. But this isn’t always the case.If the iterations are independent of each other, and you’re running on a multiprocessor machine, it might be a huge advantage if you could put different iterations on different processors and process them in parallel. This is exactly what the

    Parallel.For and Parallel.ForEach constructs do.
    Saturday, May 18, 2013 9:18 PM