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. Problem with Process.HasExited

Problem with Process.HasExited

Scheduled Pinned Locked Moved C#
debugginghelp
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.
  • N Offline
    N Offline
    Nigel Mackay
    wrote on last edited by
    #1

    Using a windows app to batch run a DOS program. Need to wait until the DOS app has finished before going on with the next file. Using:

    Process.Start(thecommand, thearguments);
    System.Diagnostics.Process p = System.Diagnostics.Process.GetCurrentProcess();
    while (!p.HasExited)
    {
    aaa=5;
    }

    but it seems to be waiting for my windows app to end, not the DOS app. I can see my DOS app running in a DOS window, and it closes when finished (it takes about a minute to run), but my app sits there in the while loop. I put a breakpoint at aaa = 5; and the app definitely sits in that loop.

    B 1 Reply Last reply
    0
    • N Nigel Mackay

      Using a windows app to batch run a DOS program. Need to wait until the DOS app has finished before going on with the next file. Using:

      Process.Start(thecommand, thearguments);
      System.Diagnostics.Process p = System.Diagnostics.Process.GetCurrentProcess();
      while (!p.HasExited)
      {
      aaa=5;
      }

      but it seems to be waiting for my windows app to end, not the DOS app. I can see my DOS app running in a DOS window, and it closes when finished (it takes about a minute to run), but my app sits there in the while loop. I put a breakpoint at aaa = 5; and the app definitely sits in that loop.

      B Offline
      B Offline
      BobJanova
      wrote on last edited by
      #2

      Uh, that's because you're assigning p to the current process, i.e. the one you are running! I think you want

      Process p = Process.Start(thecommand, thearguments);

      N 1 Reply Last reply
      0
      • B BobJanova

        Uh, that's because you're assigning p to the current process, i.e. the one you are running! I think you want

        Process p = Process.Start(thecommand, thearguments);

        N Offline
        N Offline
        Nigel Mackay
        wrote on last edited by
        #3

        I must have misunderstood the examples in the answers to other similar questions!! Working now.

        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