Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

Job results (from Receive-Job) are grouped by output type, differently than "normal" (BackgroundJob) jobs

Ouverte
#40 0 commentaires 5 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
35/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
À l'abandon
Stack technique
powershell
Domaine
backend

Piste de recherche

The issue shows the behavior with Start-ThreadJob and Receive-Job on PowerShell 7.4.5 and ThreadJob 2.1.0. Start by reproducing the example and comparing its output order with Start-Job. Trace how ThreadJob collects and exposes the different output streams; done means Receive-Job preserves the order of interleaved output types.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Consider the following code which starts a ThreadJob:

$job = Start-ThreadJob -ScriptBlock {

    for( $i = 0 ; $i -lt 100 ; $i++ )
    {
        Write-Output "output $i"
        Write-Host "host output $i"
        Write-Information "info output $i"
        Write-Verbose "verbose output $i"
        Write-Warning "warning output $i"

        Start-Sleep -Seconds 5
    }
}

If I receive results of the job, the output is grouped according to the type of output:

PS C:\Users\me> Receive-Job $job
output 0
output 1
output 2
WARNING: warning output 0
WARNING: warning output 1
WARNING: warning output 2
host output 0
host output 1
host output 2
PS C:\Users\me>

This is in contrast to “normal” jobs—if I switch the call out for Start-Job, the results come in a more expected order:

PS C:\Users\me> Receive-Job $job
output 0
host output 0
WARNING: warning output 0
output 1
host output 1
WARNING: warning output 1
output 2
host output 2
WARNING: warning output 2
PS C:\Users\me>
Expected behavior

I expect the output from Receive-Job of a ThreadJob to come in the same order as from a BackgroundJob.

This is because I expect to be able to use thread jobs as a "drop-in" replacement for background jobs (modulo restrictions imposed due to running in the same process, like of course you wouldn't be able to load different versions of .NET assemblies).

Actual behavior

The output from a ThreadJob is all grouped by output type (all Warnings grouped together, all host output grouped together, etc.).

Environment data
Name                           Value
----                           -----
PSVersion                      7.4.5
PSEdition                      Core
GitCommitId                    7.4.5
OS                             Microsoft Windows 10.0.26290
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

PS C:\Users\me> gmo *thread*

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Binary     2.1.0                 Microsoft.PowerShell.ThreadJob      Start-ThreadJob
Version

7.4.5 / 2.1.0

Langage dominant
PowerShell
Étoiles
37
Forks
22
Métriques de merge des PR
Aucune PR mergée en 30 j

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de PowerShell/ThreadJob

Toutes les issues de PowerShell/ThreadJob

Issues similaires

Plus d'issues Backend & API Design

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.