与此 v3.0 代码片段等效的 PowerShell v2.0 是什么:
for($i=0; $i -lt $num_jobs; $i++) {
Write-Host -ForegroundColor Darkgreen "[i] Job" $i "starting..."
Start-Job -ScriptBlock $insert_data -ArgumentList 'host', 'user', 'pass', 'db', $i, $log_out[$i] | Out-Null;
}
get-job | receive-job -AutoRemoveJob -Wait
我尝试了以下没有运气
for($i=0; $i -lt $num_jobs; $i++) {
Write-Host -ForegroundColor Darkgreen "[i] Job" $i "starting..."
Start-Job -ScriptBlock $insert_data -ArgumentList 'host', 'user', 'pass', 'db', $i, $log_out[$i] | Out-Null;
}
get-job | receive-job -Wait
get-job | remove-job
它在 PowerShell v2.0 上失败:
Remove-Job : The command cannot remove the job with the 3 session identifier be
cause the job is not finished. To remove the job, first stop the job, or use th
e Force parameter.