You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Receive-Job yields no output on Start-ThreadJob- or Start-Job-jobs, when listening to Completed or Failed JobState changes with Register-ObjectEvent.
$PSVersionTable dump:
Name Value
---------
PSVersion 5.1.17763.2183
PSEdition Desktop
PSCompatibleVersions {1.0,2.0,3.0,4.0...}
BuildVersion 10.0.17763.2183
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Steps to reproduce the issue:
$job=Start-ThreadJob-ScriptBlock { throw"Error trying to do a task" }
Register-ObjectEvent$job StateChanged -Action {
Write-Host ('Job #{0} ({1}) changed state: {2}'-f$sender.Id,$sender.Name,$sender.State)
if (($sender.State-eq'Completed') -or ($sender.State-eq'Failed')) {
Receive-Job$sender
}
}
When waiting for the job with Wait-Job (like suggested in this answer) the exception returns correctly, but I need a non-blocking approach. If you use Start-Job instead of Start-ThreadJob, the exception doesn't return in the event-based approach, too.
The text was updated successfully, but these errors were encountered:
Receive-Job
yields no output onStart-ThreadJob
- orStart-Job
-jobs, when listening toCompleted
orFailed
JobState changes withRegister-ObjectEvent
.$PSVersionTable dump:
Steps to reproduce the issue:
When waiting for the job with
Wait-Job
(like suggested in this answer) the exception returns correctly, but I need a non-blocking approach. If you useStart-Job
instead ofStart-ThreadJob
, the exception doesn't return in the event-based approach, too.The text was updated successfully, but these errors were encountered: