Parallel.ForEach Method
Executes a foreach (For Each in Visual Basic) operation in which iterations may run in parallel.
This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.
| Name | Description | |
|---|---|---|
|
ForEach<TSource>(IEnumerable<TSource>, Action<TSource>) | Executes a foreach (For Each in Visual Basic) operation on an IEnumerable<TSource> in which iterations may run in parallel. |
|
ForEach<TSource>(IEnumerable<TSource>, Action<TSource, ParallelLoopState>) | Executes a foreach (For Each in Visual Basic) operation on an IEnumerable<TSource> in which iterations may run in parallel, and the state of the loop can be monitored and manipulated. |
|
ForEach<TSource>(IEnumerable<TSource>, Action<TSource, ParallelLoopState, Int64>) | Executes a foreach (For Each in Visual Basic) operation with 64-bit indices on an IEnumerable<TSource> in which iterations may run in parallel, and the state of the loop can be monitored and manipulated. |
|
ForEach<TSource>(OrderablePartitioner<TSource>, Action<TSource, ParallelLoopState, Int64>) | Executes a foreach (For Each in Visual Basic) operation on a OrderablePartitioner<TSource> in which iterations may run in parallel and the state of the loop can be monitored and manipulated. |
|
ForEach<TSource>(Partitioner<TSource>, Action<TSource>) | Executes a foreach (For Each in Visual Basic) operation on a Partitioner<TSource> in which iterations may run in parallel. |
|
ForEach<TSource>(Partitioner<TSource>, Action<TSource, ParallelLoopState>) | Executes a foreach (For Each in Visual Basic) operation on a Partitioner<TSource> in which iterations may run in parallel, and the state of the loop can be monitored and manipulated. |
|
ForEach<TSource>(IEnumerable<TSource>, ParallelOptions, Action<TSource>) | Executes a foreach (For Each in Visual Basic) operation on an IEnumerable<TSource> in which iterations may run in parallel amd loop options can be configured. |
|
ForEach<TSource>(IEnumerable<TSource>, ParallelOptions, Action<TSource, ParallelLoopState>) | Executes a foreach (For Each in Visual Basic) operation on an IEnumerable<TSource> in which iterations may run in parallel, loop options can be configured, and the state of the loop can be monitored and manipulated. |
|
ForEach<TSource>(IEnumerable<TSource>, ParallelOptions, Action<TSource, ParallelLoopState, Int64>) | Executes a foreach (For Each in Visual Basic) operation with 64-bit indices on an IEnumerable<TSource> in which iterations may run in parallel, loop options can be configured, and the state of the loop can be monitored and manipulated. |
|
ForEach<TSource>(OrderablePartitioner<TSource>, ParallelOptions, Action<TSource, ParallelLoopState, Int64>) | Executes a foreach (For Each in Visual Basic) operation on a OrderablePartitioner<TSource> in which iterations may run in parallel, loop options can be configured, and the state of the loop can be monitored and manipulated. |
|
ForEach<TSource>(Partitioner<TSource>, ParallelOptions, Action<TSource>) | Executes a foreach (For Each in Visual Basic) operation on a Partitioner<TSource> in which iterations may run in parallel and loop options can be configured. |
|
ForEach<TSource>(Partitioner<TSource>, ParallelOptions, Action<TSource, ParallelLoopState>) | Executes a foreach (For Each in Visual Basic) operation on a Partitioner<TSource> in which iterations may run in parallel, loop options can be configured, and the state of the loop can be monitored and manipulated.. |
|
ForEach<TSource, TLocal>(IEnumerable<TSource>, Func<TLocal>, Func<TSource, ParallelLoopState, TLocal, TLocal>, Action<TLocal>) | Executes a foreach (For Each in Visual Basic) operation with thread-local data on an IEnumerable<TSource> in which iterations may run in parallel, and the state of the loop can be monitored and manipulated. |
|
ForEach<TSource, TLocal>(IEnumerable<TSource>, Func<TLocal>, Func<TSource, ParallelLoopState, Int64, TLocal, TLocal>, Action<TLocal>) | Executes a foreach (For Each in Visual Basic) operation with thread-local data on an IEnumerable<TSource> in which iterations may run in parallel and the state of the loop can be monitored and manipulated. |
|
ForEach<TSource, TLocal>(OrderablePartitioner<TSource>, Func<TLocal>, Func<TSource, ParallelLoopState, Int64, TLocal, TLocal>, Action<TLocal>) | Executes a foreach (For Each in Visual Basic) operation with thread-local data on a OrderablePartitioner<TSource> in which iterations may run in parallel, loop options can be configured, and the state of the loop can be monitored and manipulated. |
|
ForEach<TSource, TLocal>(Partitioner<TSource>, Func<TLocal>, Func<TSource, ParallelLoopState, TLocal, TLocal>, Action<TLocal>) | Executes a foreach (For Each in Visual Basic) operation with thread-local data on a Partitioner<TSource> in which iterations may run in parallel and the state of the loop can be monitored and manipulated. |
|
ForEach<TSource, TLocal>(IEnumerable<TSource>, ParallelOptions, Func<TLocal>, Func<TSource, ParallelLoopState, TLocal, TLocal>, Action<TLocal>) | Executes a foreach (For Each in Visual Basic) operation with thread-local data on an IEnumerable<TSource> in which iterations may run in parallel, loop options can be configured, and the state of the loop can be monitored and manipulated.. |
|
ForEach<TSource, TLocal>(IEnumerable<TSource>, ParallelOptions, Func<TLocal>, Func<TSource, ParallelLoopState, Int64, TLocal, TLocal>, Action<TLocal>) | Executes a foreach (For Each in Visual Basic) operation with thread-local data and 64-bit indices on an IEnumerable<TSource> in which iterations may run in parallel, loop options can be configured, and the state of the loop can be monitored and manipulated. |
|
ForEach<TSource, TLocal>(OrderablePartitioner<TSource>, ParallelOptions, Func<TLocal>, Func<TSource, ParallelLoopState, Int64, TLocal, TLocal>, Action<TLocal>) | Executes a foreach (For Each in Visual Basic) operation with 64-bit indices and with thread-local data on a OrderablePartitioner<TSource> in which iterations may run in parallel , loop options can be configured, and the state of the loop can be monitored and manipulated. |
|
ForEach<TSource, TLocal>(Partitioner<TSource>, ParallelOptions, Func<TLocal>, Func<TSource, ParallelLoopState, TLocal, TLocal>, Action<TLocal>) | Executes a foreach (For Each in Visual Basic) operation with thread-local data on a Partitioner<TSource> in which iterations may run in parallel, loop options can be configured, and the state of the loop can be monitored and manipulated. |
TPL is Awesome.....examples?
$0 I found a good one with integers here, but I want to re-factor a bit and use string results instead... $0
$0http://msdn.microsoft.com/en-us/library/dd997393.aspx$0
$0$0
$0
$0
$0For example, how would I convert this to parallel?$0
$0
$0$0
$0Imports System.Threading$0
$0Imports System.Threading.Tasks$0
$0$0
$0
$0Module ForEachThreadLocal$0
$0 Sub Main()$0
$0 Dim servers() As String = System.IO.File.ReadAllLines("servers.txt")$0
$0 Dim Results As String = ""$0
$0 For Each server In servers$0
$0 results &= myfunction(server)$0
$0 Next$0
$0$0
$0System.IO.File.AppendAllText("results.txt", results)$0
$0$0
$0
$0 End Sub$0
$0$0
$0
$0
$0 Function myfunction(ByVal servername As String)$0
$0 Dim retstr As String = ""$0
$0 'do work$0
$0 Return retstr$0
$0 End Function$0
$0
$0End Module$0
$0
- 10/22/2011
- nujakcities