tags:

views:

48

answers:

2

Hello all

I need to call from my code for some other program .

And I need to wait till it finishes (synchronous call).

How I can do so ?

Thanks, a lot.

+2  A: 

Try using the WaitForExit method.

 Process p = new Process();
 // Redirect the error stream of the child process.
 p.StartInfo.UseShellExecute = false;
 p.StartInfo.RedirectStandardError = true;
 p.StartInfo.FileName = "OtherProgram.exe";
 p.StartInfo.Arguments = "My Arguments";
 p.Start();
 // Wait for the child process to exit.
 p.WaitForExit();
smoore
How i can send there arguments ?
Night Walker
Added it in to the code above. This link shows a couple different ways of doing it as well: http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx
smoore
A: 

Unless you explicitly make an asynchronous the call will be synchronous (and therefore block the current thread). The details of doing these depend on the selected application to application communication mechanism you are using.

This could be:

  • TCP/IP
  • HTTP
  • WCF
  • SharedMemory
  • Named Pipes

and many more. All of these allow you to wait for a response.

But the specifics are very different (as is when you would use each), so without more details of the type of communications you are trying to achieve one cannot be more specific.

Richard
I only need to know that it had finish it's work.
Night Walker