Skip to content

Invoke Parallel

apobekiaris edited this page May 23, 2019 · 3 revisions

schema: 2.0.0

Invoke-Parallel

SYNOPSIS

Invokes tasks in parallel.

SYNTAX

Invoke-Parallel [-Script] <ScriptBlock> [-VariablesToImport <String[]>] [-Value] <Object>
 [-RetryOnError <Int32>] [-RetryDelay <Int32>] [-StepInterval <Int32>] [<CommonParameters>]

DESCRIPTION

Invokes tasks in parallel. The function uses the System.Reactive library to handle parallelism.

EXAMPLES

Example 1

PS C:\> $psObj=[PSCustomObject]@{
    PackagesDirectory = (Get-Item "$PSScriptRoot\..\_third_party_assemblies\Packages").FullName
    packageSources=[system.string]::join(";",$packageSources)
    projects=$projects
} 
$nuget=Get-XNugetPath

$psObj.Projects|Invoke-XParallel -ActivityName "Restoring Nugets" -VariablesToImport @("psObj","nuget") -Script {
    & $nuget Restore $_ -PackagesDirectory $psObj.PackagesDirectory -source $psObj.packageSources
}

The above script restores in parallel all eXpandFrameowrk NuGets.

PARAMETERS

-RetryDelay

In case of error how long to wait until Retrying.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-RetryOnError

If should retry on error.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Script

The script to execute in parallel

Type: ScriptBlock
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-StepInterval

Throttling parallelism.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Value

The input for each script executed in parallel.

Type: Object
Parameter Sets: (All)
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-VariablesToImport

An array of variable names with the $

Type: String[]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

System.Object

OUTPUTS

System.Object

NOTES

RELATED LINKS

Star the project if you think it deserves it.

GitHub stars

Fork the project to extend and contribute.

GitHub forks

Clone this wiki locally
You can’t perform that action at this time.