views:

91

answers:

1

Hi,

Simple question.

I see that Jean-Paul Mikkers async poweshell example over at code project is tearing down the pipeline and recreating it after every script execution. Does anybody know if there is a particular reason why it's done this way, or does the pipeline need to be recreated every time.

I've tried execution on it multiple times with my own example, but it could be their is knock on effects which I don't see with only a few exections.

regards Bob.

A: 

I have (unit test) code which creates a single Runspace to create multiple pipelines, none of which are disposed,1 in turn.

This all runs without problem.

Of course, if a pipeline changes the state of the Runspace (e.g. adds a variable, changes directory, loads a snapin, ...) then this could impact the result of pipelines.

Summary: "Is it neccessary?": No. But you might find it gives better/worse performance (and the answer to this will vary with PSH version). Unless you find creating the pipeline causes a performance impact, follow what provides the simplest design for your application.


1 One for the to do list :-)

Richard
In other words, the question is do you want to enforce a clean environment?
JasonMArcher
@Jason: indeed. Will clarify.
Richard