private void HandleJobOutput(Job job, TSession sessionForJob, bool discardNonPipelineResults, Action <PSObject> outputAction)
        {
            Action <PSObject> processOutput = delegate(PSObject pso)
            {
                if ((pso != null) && (outputAction != null))
                {
                    outputAction(pso);
                }
            };

            job.Output.DataAdded += delegate(object sender, DataAddedEventArgs eventArgs)
            {
                PSDataCollection <PSObject> datas = (PSDataCollection <PSObject>)sender;
                if (discardNonPipelineResults)
                {
                    foreach (PSObject obj2 in datas.ReadAll())
                    {
                        processOutput(obj2);
                    }
                }
                else
                {
                    PSObject obj3 = datas[eventArgs.Index];
                    processOutput(obj3);
                }
            };
            if (discardNonPipelineResults)
            {
                SessionBasedCmdletAdapter <TObjectInstance, TSession> .DiscardJobOutputs(job, JobOutputs.Progress | JobOutputs.Debug | JobOutputs.Verbose | JobOutputs.Warning | JobOutputs.Error);
            }
        }