View Single Post
Old 08-21-2008   #3 (permalink)
rmq


 
 

Re: inconsistent behavior

On Aug 20, 4:38*pm, tojo2000 <tojo2...@xxxxxx> wrote:
Quote:

> On Aug 19, 11:40*pm, rmq <zhangf...@xxxxxx> wrote:
>
>
>
Quote:

> > In powershell console, I typed "calc", then "windows caculator"
> > appear, then powershell immediately returned and I could type other
> > commands, though "windows caculator" are still running.
>
Quote:

> > But if I wrote the following code in VS, I must manually close
> > "windows caculator" first, the Main function return.
>
Quote:

> > So, why the behaviors are inconsistent?
>
Quote:

> > using ....
> > namespace Host3 {
> > * * class Program {
> > * * * * static void Test2() {
> > * * * * * * Runspace runspace = RunspaceFactory.CreateRunspace();
> > * * * * * * runspace.Open();
> > * * * * * * Pipeline pipeline = runspace.CreatePipeline("calc");
> > * * * * * * pipeline.Invoke();
> > * * * * * * runspace.Close();
> > * * * * }
> > * * * * static void Main(string[] args) {
> > * * * * * * Test2();
> > * * * * }
> > * * }
>
Quote:

> > }
>
> My C# foo isn't terribly strong, but I believe the problem is that
> you're creating a pipeline that is going to keep waiting for output
> from the command, because rather than just spawning a process you're
> holding open the pipeline for it.
>
> The same thing happens if *you type this in at the prompt:
>
> calc | select *
>
> Your command won't return until calc.exe exits because the pipeline is
> waiting for objects.
I agree with you , because the host application does not need a return
value, so host return to prompt quickly.
but do you know how to config and make the host must wait "calc"
return?
thx
My System SpecsSystem Spec