Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Process.HasExited and Process.WaitForExit() in C#

Process.HasExited and Process.WaitForExit() in C#

Scheduled Pinned Locked Moved C#
helpcsharpdebugging
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    danielhasdibs
    wrote on last edited by
    #1

    I've got a serious problem with these two. In short, they aren't working or I'm not doing it right (I'm hoping it's the latter). I am trying to open a Word document. After the user closes the Word document, I want to start another process (namely, a web address). Every time, the processes open one after the other -- without pausing or anything. Here is the code I have (and I have tried various rearrangements): System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(); psi.RedirectStandardOutput = true; psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized; psi.UseShellExecute = false; psi.Arguments = @txt_Wordfile.Text; psi.FileName = @WordExe]; System.Diagnostics.Process WordProcess = new System.Diagnostics.Process(); WordProcess = System.Diagnostics.Process.Start(psi); WordProcess.EnableRaisingEvents = true; WordProcess.WaitForExit(); System.Diagnostics.Process.Start(txt_website.Text); Even in debug mode, it shows WordProcess.HasExited == true right after the process starts. Also, the window does not open maximized. Please help! Thanks!

    S 1 Reply Last reply
    0
    • D danielhasdibs

      I've got a serious problem with these two. In short, they aren't working or I'm not doing it right (I'm hoping it's the latter). I am trying to open a Word document. After the user closes the Word document, I want to start another process (namely, a web address). Every time, the processes open one after the other -- without pausing or anything. Here is the code I have (and I have tried various rearrangements): System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(); psi.RedirectStandardOutput = true; psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized; psi.UseShellExecute = false; psi.Arguments = @txt_Wordfile.Text; psi.FileName = @WordExe]; System.Diagnostics.Process WordProcess = new System.Diagnostics.Process(); WordProcess = System.Diagnostics.Process.Start(psi); WordProcess.EnableRaisingEvents = true; WordProcess.WaitForExit(); System.Diagnostics.Process.Start(txt_website.Text); Even in debug mode, it shows WordProcess.HasExited == true right after the process starts. Also, the window does not open maximized. Please help! Thanks!

      S Offline
      S Offline
      Skippums
      wrote on last edited by
      #2

      I think that this is due to the fact that Word starts up by opening an intermediary executable, which is killed immediately after it loads the actual Word executable. What you should probably do is use the windows handle to call the win api method ShowWindow to maximize after you instantiate word (look for windows with class name "OpusApp"). Hope this helps,

      Sounds like somebody's got a case of the Mondays -Jeff

      D 1 Reply Last reply
      0
      • S Skippums

        I think that this is due to the fact that Word starts up by opening an intermediary executable, which is killed immediately after it loads the actual Word executable. What you should probably do is use the windows handle to call the win api method ShowWindow to maximize after you instantiate word (look for windows with class name "OpusApp"). Hope this helps,

        Sounds like somebody's got a case of the Mondays -Jeff

        D Offline
        D Offline
        danielhasdibs
        wrote on last edited by
        #3

        I think I know what you're talking about, but just in case I'm wrong, could you put that in a sample code? Thanks!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups