vscode-powershell: VS Code does not run PowerShell jobs correctly

$test = {
  function makeform {     
          [void][reflection.assembly]::LoadWithPartialName("System.Windows.Forms")    
          [System.Windows.Forms.Application]::EnableVisualStyles();    

          $form = New-Object Windows.Forms.Form    
          $form.Text = 'Test Form'    

          $form.Add_Shown({$form.Activate()})    
          $form.ShowDialog()    
  }
}

Start-Job { makeform } -InitializationScript $test
---------------------------------
PS C:\WINDOWS\system32> D:\AMS\scripts\MaybeBug.ps1
Id     Name            PSJobTypeName   State         HasMoreData     Location             Command               
--     ----            -------------   -----         -----------     --------             -------               
7      Job7            BackgroundJob   Running       True            localhost             makeform

----------------------------------
Visual Stu
Id     Name            PSJobTypeName   State         HasMoreData     Location             Command                  
--     ----            -------------   -----         -----------     --------             -------                  
1      Job1            BackgroundJob   Failed        False           localhost             makeform    

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 2
  • Comments: 17 (6 by maintainers)

Most upvoted comments

Awesome! Keep your eyes out for this in the next release!

I bet the issue that @GoateePFE is seeing is the same bug as https://github.com/PowerShell/PowerShellEditorServices/issues/554. It only happens on non-Windows systems. I know right where the issue lies (documented in the aforementioned issue and my first attempt to fix it - https://github.com/PowerShell/PowerShellEditorServices/pull/557).

@tylerl0706 In the Windows PowerShell Integrated Scripting Editor (ISE), F8 became the standard shortcut to run the “current line” that the cursor is on (if there is no editor selection) or “current selection” (if there is an editor selection).

So, I’m guessing that what @GoateePFE means by “F8 method” is that he’s simply putting the cursor on a line with a Start-Job command and simply hitting F8 to invoke that line, as opposed to manually typing the Start-Job command into the VSCode Integrated Terminal.