checkNewData() //starts the looping function
function checkIfAutoLoadOn(){
if(autoload_switch === "on")
setTimeout(checkNewData(), 7000);
}
function checkNewData() {
//Check if solutions
$.ajax({
async: true,
type: "POST",
url: "cgi-bin/check_NewData.py",
contentType: "application/x-www-form-urlencoded;charset=ISO-8859-15",
data: JSON.stringify(data_refs),
dataType: "json"
})
.done(function(result) {
if (result["new_data"]==="true") {
// Do sth with data
} else if (result["new_data"]==="false") {
//Check again in some seconds if new data arrived
checkIfAutoLoadOn()
}
})
}
在上面的代码片段中,我想开始一个工作并为function F2([String]$var2) {
...
}
function F1([String]$var1) {
...
F2 $var2
...
}
...
while ($i -le $count) {
F1 "dir$i"
Start-Job -ScriptBlock ${function:F1} -ArgumentList @($i)
$i = $i + 1
}
循环的每次迭代运行F1
。虽然while
中定义的内容正常,但F1
对F1
的调用似乎不会通过脚本块完成,因为F2
超出了范围。我可以在这里使用任何替代方案吗?