Skip to content

Instantly share code, notes, and snippets.

@rodmhgl
Created May 7, 2015 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodmhgl/3d7b59f25b5c1a5642f7 to your computer and use it in GitHub Desktop.
Save rodmhgl/3d7b59f25b5c1a5642f7 to your computer and use it in GitHub Desktop.
$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