我正在尝试创建一个简单的控制台计时器显示。PowerShell控制台计时器
...
$rpt = $null
write-status "Opening report", $rpt
# long-running
$rpt = rpt-open -path "C:\Documents and Settings\foobar\Desktop\Calendar.rpt"
...
function write-status ($msg, $obj) {
write-host "$msg" -nonewline
do {
sleep -seconds 1
write-host "." -nonewline
[System.Windows.Forms.Application]::DoEvents()
} while ($obj -eq $null)
write-host
}
该示例生成'打开报告....',但循环不会退出。
我应该使用回调或委托,但我不确定在这种情况下的模式。
我错过了什么?
有人刚刚学到了一些新东西......我! – 2013-03-21 06:04:11