Invoke() public method

Invokes the pipeline synchronously.
When this method is used to invoke the pipeline, the Windows PowerShell runtime closes the Input pipe. This method cannot be called when another pipeline is running. This method cannot be called multiple times on a given pipeline. The state of the pipeline must be NotStarted when Invoke is called. When this method is called, it changes the state of the pipeline to Running. When Invoke is completed, it changes the state of the pipeline to one of following: Completed: The pipeline state is Completed if the pipeline invocation completed successfully. Failed: The pipeline state is Failed if the pipeline invocation failed or one of the commands in the pipeline threw a terminating error. Stopped: The pipeline state is Stopped if the pipeline was stopped by calling Stop or StopAsync. Applications can get notified about pipeline state changes by registering for the StateChanged event. This event is raised each time the state of the pipeline changes.
public Invoke ( ) : Collection
return Collection
示例#1
0
        public void InvokeDelegatesToWrappedPipeline()
        {
            // Arrange.
            var runspace = RunspaceFactory.CreateRunspace();
            runspace.Open();
            var expectedPipeline = runspace.CreatePipeline("1+1");
            var wrapper = new PipelineWrapper(expectedPipeline);

            // Act.
            var res = wrapper.Invoke();

            // Assert.
            Assert.AreEqual(2, (int)res[0].BaseObject);
        }