-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
outsideconfigforBackgroundWorkScript.ps1
42 lines (31 loc) · 1.1 KB
/
outsideconfigforBackgroundWorkScript.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# command that runs on background
$work = {
param($this, $o)
"$(Get-Date) Ping" | Out-File -FilePath "c:\temp\put.txt" -Append
[System.Windows.Threading.Dispatcher]::CurrentDispatcher.Invoke({ $syncHash.this.SetProgress(10)});
Start-Sleep -Seconds 2
[System.Windows.Threading.Dispatcher]::CurrentDispatcher.Invoke({ $syncHash.this.SetProgress(50)});
Start-Sleep -Seconds 2
[System.Windows.Threading.Dispatcher]::CurrentDispatcher.Invoke({ $syncHash.this.SetProgress(99)});
}
$callback = {
param($this)
function w ($string) {
$string | Out-File -FilePath "c:\temp\put.txt" -Append
}
w ($null -eq $this)
$this.SetValue("2234")
w "Dispatcher done"
}
$afterWork =
{
[System.Windows.Threading.Dispatcher]::CurrentDispatcher.Invoke({
function w ($string) {
$string | Out-File -FilePath "c:\temp\put.txt" -Append
}
w ("callback $($synchash.callback)")
&$syncHash.CallBack $syncHash.This
})
}
# main worker that builds the runspace and invokes work in it
$d =