NuGetConsole.Host.PowerShell.Implementation.RunspaceDispatcher.InvokeAsync C# (CSharp) Method

InvokeAsync() private method

private InvokeAsync ( string command, object inputs, bool outputResults, EventHandler pipelineStateChanged ) : System.Management.Automation.Runspaces.Pipeline
command string
inputs object
outputResults bool
pipelineStateChanged EventHandler
return System.Management.Automation.Runspaces.Pipeline
        public Pipeline InvokeAsync(
            string command,
            object[] inputs,
            bool outputResults,
            EventHandler<PipelineStateEventArgs> pipelineStateChanged)
        {

            if (String.IsNullOrEmpty(command))
            {
                throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, CommonResources.Argument_Cannot_Be_Null_Or_Empty, command), "command");
            }

            Pipeline pipeline = CreatePipeline(command, outputResults);

            pipeline.StateChanged += (sender, e) =>
            {
                pipelineStateChanged.Raise(sender, e);

                // Dispose Pipeline object upon completion
                switch (e.PipelineStateInfo.State)
                {
                    case PipelineState.Completed:
                    case PipelineState.Failed:
                    case PipelineState.Stopped:
                        ((Pipeline)sender).Dispose();
                        break;
                }
            };

            InvokeCoreAsync(pipeline, inputs);
            return pipeline;
        }