0
我在調用SSIS包的字符串數組中有多個命令。 爲了利用硬件,我希望一次運行多個軟件包,等待一個完成後再添加另一個軟件包。通過觀察上的其他類似的問題,我覺得像這樣的工作:Powershell中多處理exec的高達閾值
cls
$commands = @()
$commands += "notepad.exe"
$commands += "notepad.exe"
$commands += "notepad.exe"
$commands += "notepad.exe"
$commands += "notepad.exe"
$commands += "notepad.exe"
foreach ($instance in $commands)
{
$running = @(Get-Job | Where-Object { $_.JobStateInfo.State -eq 'Running' })
if ($running.Count -le 2)
{
Start-Process $instance
}
else
{
$running | Wait-Job
}
Get-Job | Receive-Job
}
這不管理,打開記事本6分的,但它不會在某個閾值等待 - 在本例中2。理想情況下,它應該等到我關閉其中一個記事本(即過程結束)。
以前有人會這樣做嗎?