Hi VBForums. The past few days I have been reading a bit about when to use the Task Parallel Library for CPU bound tasks.
However, the Parallel.For method is actually performing worse than a standard For loop.
For testing, all I am doing is incrementing an integer variable +1 on each iteration.
Dim number as Integer = 0
For i = 0 To Integer.MaxValue - 1
number += 1
Next
This takes 4 seconds for the 21 billion iterations, but when I use Parallel.For, it is taking much longer too complete.
Isn't adding an integer to another integer a CPU bound task?
Thanks!
However, the Parallel.For method is actually performing worse than a standard For loop.
For testing, all I am doing is incrementing an integer variable +1 on each iteration.
Dim number as Integer = 0
For i = 0 To Integer.MaxValue - 1
number += 1
Next
This takes 4 seconds for the 21 billion iterations, but when I use Parallel.For, it is taking much longer too complete.
Isn't adding an integer to another integer a CPU bound task?
Thanks!