我正在尝试在ScriptBlock中更改一个变量。 我做错了什么吗?
$reader=(New-Object System.Xml.XmlNodeReader $xaml)
$Window=[Windows.Markup.XamlReader]::Load($reader)
$Window.Add_SourceInitialized( {
$timer = new-object System.Windows.Threading.DispatcherTimer
$timer.Interval = [TimeSpan]"0:0:0.25"
$timer.Add_Tick( $updateBlock )
$timer.Start()
} )
$count = 0
$updateBlock = { Write-Host $count; $count++; Write-Host $count}
输出是由0和1的重复序列组成的。那么我如何访问变量而不仅仅是它的副本?
$count++
->([ref]$count).Value++
- user4003407