Wait-SpectreJobs
Description
This function waits for Spectre jobs to complete by checking the progress of each job and updating the corresponding task value. Adapted from https://key2consulting.com/powershell-how-to-display-job-progress/
Examples
EXAMPLE 1
Invoke-SpectreCommandWithProgress -ScriptBlock {
param (
$Context
)
$jobs = @()
$jobs += Add-SpectreJob -Context $Context -JobName "job 1" -Job (Start-Job { Start-Sleep -Seconds 2 })
$jobs += Add-SpectreJob -Context $Context -JobName "job 2" -Job (Start-Job { Start-Sleep -Seconds 4 })
Wait-SpectreJobs -Context $Context -Jobs $jobs
}
Parameters
Context
The Spectre progress context object. https://spectreconsole.net/api/spectre.console/progresscontext/
Type | Required | Position | PipelineInput |
---|---|---|---|
[Object] | true | 1 | false |
Jobs
An array of Spectre jobs which are decorated PowerShell jobs.
Type | Required | Position | PipelineInput |
---|---|---|---|
[Array] | true | 2 | false |
TimeoutSeconds
The maximum number of seconds to wait for the jobs to complete. Defaults to 60 seconds.
Type | Required | Position | PipelineInput |
---|---|---|---|
[Int32] | false | 3 | false |
EstimatedDurationSeconds
The estimated duration of the jobs in seconds. This is used to calculate the progress of the jobs if the job progress is not available.
Type | Required | Position | PipelineInput |
---|---|---|---|
[Int32] | false | 4 | false |
Syntax
Wait-SpectreJobs [-Context] <Object> [-Jobs] <Array> [[-TimeoutSeconds] <Int32>] [[-EstimatedDurationSeconds] <Int32>] [<CommonParameters>]