Execute external program synchronously

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SC

    #1

    Execute external program synchronously

    Hi,

    I want tu run an external program from a c# program but i need to wait until
    the external program ends. How can i do that? I try Process.Start but it do
    asynchronously. .. Any help?

    Bye


  • Lee Alexander

    #2
    Re: Execute external program synchronously


    Process.Start returns a Process object. The Process object has an overloaded
    method called WaitForExit. The first overload will block your process untill
    the spawned process has finished. The second overload allows you specifiy
    how long to wait before returning control to your process.

    Regards
    Lee

    "SC" <s_castro@hotma il.com> wrote in message
    news:OMmiYfkbDH A.1492@TK2MSFTN GP12.phx.gbl...[color=blue]
    > Hi,
    >
    > I want tu run an external program from a c# program but i need to wait[/color]
    until[color=blue]
    > the external program ends. How can i do that? I try Process.Start but it[/color]
    do[color=blue]
    > asynchronously. .. Any help?
    >
    > Bye
    >
    >[/color]


    Comment

    • Peter Rilling

      #3
      Re: Execute external program synchronously

      You can use the Process.WaitFor Exit method.

      "SC" <s_castro@hotma il.com> wrote in message
      news:OMmiYfkbDH A.1492@TK2MSFTN GP12.phx.gbl...[color=blue]
      > Hi,
      >
      > I want tu run an external program from a c# program but i need to wait[/color]
      until[color=blue]
      > the external program ends. How can i do that? I try Process.Start but it[/color]
      do[color=blue]
      > asynchronously. .. Any help?
      >
      > Bye
      >
      >[/color]


      Comment

      Working...