Created
October 28, 2014 23:05
-
-
Save kgadek/e402a3edb18bd0e0682d to your computer and use it in GitHub Desktop.
Powershell parallel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cls | |
"foo.txt", "bar.txt" | %{ | |
$ScriptBlock = { | |
param($name) | |
Write-Host "[processing '$name' inside the job]" | |
Get-Content "$name" | %{ | |
Write-Host "Content: $_" | |
} | |
Start-Sleep 1 | |
} | |
Write-Host "processing $_..." | |
Start-Job $ScriptBlock -ArgumentList $_ | |
} | |
While (Get-Job -State "Running") { Start-Sleep 1 } | |
Get-Job | Receive-Job | |
Remove-Job * |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment