I recently learned this bit of code the other day...

Code:
        Directory.GetFiles(fileLoc).AsParallel.WithDegreeOfParallelism(3).ForAll(Sub(path) theWorker(path))
and it has drastically improved a few of my programs and it has me wondering if this could also be used on nested for statements?


Code:
       For x As Integer = 0 To 99
            For y As Integer = 0 To 99
                For z As Integer = 0 To 99
                   dowork(x, y, z)
                Next
            Next
        Next
would it be possible to do something like this?


Code:
       For x As Integer = 0 To 99
            For y As Integer = 0 To 99
                Parallel.For(0,99,Sub(z) dowork(x,y,z).WithDegreeOfParallelism(3)
            Next
        Next
or would I have to do something like this to actually make it work?

Code:
        Dim thelist As New List(Of String)

        For x As Integer = 0 To 99
            thelist.Add(x)
        Next


        For x As Integer = 1 To 26
            For y As Integer = 0 To 23
                thelist.AsParallel.WithDegreeOfParallelism(3).ForAll(Sub(z) dowork(x,y,z))
            Next
        Next
If someone could teach me it would be greatly appreciated : )

Thanks -Z