Skip to content

M_CodeJam_Threading_ParallelExtensions_RunInParallel__2_1

andrewvk edited this page Mar 30, 2016 · 7 revisions

ParallelExtensions.RunInParallel(TSource, TTarget) Method (IEnumerable(TSource), Func(TSource, TTarget), Int32, Action(TTarget), String)

[This is preliminary documentation and is subject to change.]

Implements Provider-Consumer pattern.

Namespace: CodeJam.Threading
Assembly: CodeJam (in CodeJam.dll) Version: 1.0.0.0 (1.0.0.0)

Syntax

C#

public static void RunInParallel<TSource, TTarget>(
	[NotNullAttribute][InstantHandleAttribute] this IEnumerable<TSource> source,
	[NotNullAttribute][InstantHandleAttribute] Func<TSource, TTarget> providerFunc,
	int consumerCount,
	[NotNullAttribute][InstantHandleAttribute] Action<TTarget> consumerAction,
	string processName = "ParallelProcess"
)

VB

<ExtensionAttribute>
Public Shared Sub RunInParallel(Of TSource, TTarget) ( 
	<NotNullAttribute><InstantHandleAttribute> source As IEnumerable(Of TSource),
	<NotNullAttribute><InstantHandleAttribute> providerFunc As Func(Of TSource, TTarget),
	consumerCount As Integer,
	<NotNullAttribute><InstantHandleAttribute> consumerAction As Action(Of TTarget),
	Optional processName As String = "ParallelProcess"
)

F#

[<ExtensionAttribute>]
static member RunInParallel : 
        [<NotNullAttribute>][<InstantHandleAttribute>] source : IEnumerable<'TSource> * 
        [<NotNullAttribute>][<InstantHandleAttribute>] providerFunc : Func<'TSource, 'TTarget> * 
        consumerCount : int * 
        [<NotNullAttribute>][<InstantHandleAttribute>] consumerAction : Action<'TTarget> * 
        ?processName : string 
(* Defaults:
        let _processName = defaultArg processName "ParallelProcess"
*)
-> unit 

Parameters

 

source
Type: System.Collections.Generic.IEnumerable(TSource)
Incoming data.
providerFunc
Type: System.Func(TSource, TTarget)
Provider function
consumerCount
Type: System.Int32
Number of consumer threads.
consumerAction
Type: System.Action(TTarget)
Consumer action.
processName (Optional)
Type: System.String
Process name pattern.

Type Parameters

 

TSource
TTarget

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable(TSource). When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also

Reference

ParallelExtensions Class
RunInParallel Overload
CodeJam.Threading Namespace

Clone this wiki locally