PoshRSJob icon indicating copy to clipboard operation
PoshRSJob copied to clipboard

Incorrect job counting

Open MVKozlov opened this issue 7 years ago • 2 comments

There is a bug based on #169

Code sample:

1 .. 2 | Foreach-Object {
  $_ | Start-RSJob {
     $_
     (10 * $_ + 1) .. (10 * $_ + 5) | Start-RSJob { $_ } | Wait-RSJob | Receive-RSJob
  }
}
Get-RSJob
Get-RSJob | Receive-RSJob

Currently Receive-RSJob returned correct result, but Get-RSJob return only 2 jobs

I expect that Get-RSJob should return 12 jobs

MVKozlov avatar Oct 21 '17 16:10 MVKozlov

@MVKozlov Is this one fixed with one of the previous PRs? I'm trying to play cleanup on old issues.

proxb avatar Feb 14 '18 19:02 proxb

It seems this is not bug, but powershell-by-design feature. $global:variable defined inside start-rsjob {} block (i.e. inside child runspace) do not correlate with $global:variable in main runspace. It can be fixed by using synchronized hash, but I'm not sure if we should do this

MVKozlov avatar Feb 15 '18 08:02 MVKozlov