Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $hashUI = [hashtable]::Synchronized(@{})
- $backgroundRS = [runspacefactory]::CreateRunspace()
- $backgroundRS.ApartmentState = "STA"
- $backgroundRS.ThreadOptions = "ReuseThread"
- $backgroundRS.Open()
- $backgroundRS.SessionStateProxy.SetVariable("hashUI", $hashUI)
- $hashUI.BackgroundJobInfo = [powershell]::Create().AddScript({
- while ($true) {
- # ... do something periodically
- Start-Sleep -Seconds 60
- }
- })
- $hashUI.BackgroundJobInfo.Runspace = $backgroundRS
- $hashUI.BackgroundJob = $hashUI.BackgroundJobInfo.BeginInvoke()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement