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;
}