Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim loopCount As Integer = 500
- Dim regularSum = Enumerable.Range(0, loopCount).Select(Function(n) Clng(n)).Sum
- regularSum.Dump("Correct value")
- Dim results = Enumerable.Range(0, 10).Select(Function(d)
- Dim total As Long = 0
- Parallel.For(0, loopCount, New ParallelOptions() With {.MaxDegreeOfParallelism = 8},
- Sub(n)
- 'this code is running in multiple tasks and not running in the same thread.
- total += CLng(n)
- End Sub)
- Return total
- End Function).ToList
- results.Dump("Bad way. Don't do this ever")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement