Created
May 7, 2015 20:29
-
-
Save rodmhgl/3d7b59f25b5c1a5642f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$buttonStartJob_Click={ | |
$buttonStartJob.Enabled = $false | |
#Create a New Job using the Job Tracker | |
Add-JobTracker -Name "JobName" ` | |
-JobScript { | |
#-------------------------------------------------- | |
#TODO: Set a script block | |
#Important: Do not access form controls from this script block. | |
Param($Argument1)#Pass any arguments using the ArgumentList parameter | |
#for($i = 0; $i -lt 50; $i++){ Start-Sleep -Milliseconds 100 } | |
get-service | |
#-------------------------------------------------- | |
}` | |
-CompletedScript { | |
Param($Job) | |
$results = Receive-Job -Job $Job | |
$results | Out-GridView | |
#Enable the Button | |
$buttonStartJob.ImageIndex = -1 | |
$buttonStartJob.Enabled = $true | |
}` | |
-UpdateScript { | |
Param($Job) | |
#$results = Receive-Job -Job $Job -Keep | |
#Animate the Button | |
if($buttonStartJob.ImageList -ne $null) | |
{ | |
if($buttonStartJob.ImageIndex -lt $buttonStartJob.ImageList.Images.Count - 1) | |
{ | |
$buttonStartJob.ImageIndex += 1 | |
} | |
else | |
{ | |
$buttonStartJob.ImageIndex = 0 | |
} | |
} | |
} | |
} | |
$buttonGetService_Click={ | |
$this.Enabled = $False | |
#TODO: Place custom script here | |
Get-Service | Out-GridView | |
#Process the pending messages before enabling the button | |
[System.Windows.Forms.Application]::DoEvents() | |
$this.Enabled = $True | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment