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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Waiting for a Process to end without freezing the starting app

Waiting for a Process to end without freezing the starting app

Scheduled Pinned Locked Moved C#
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
    Dan Neely
    wrote on last edited by
    #1

    Process.WaitForExit() is a blocking call. Is there a nonblocking equivilant, or will I need to call the 2nd app from a thread. I need to know when it's finished so that I can clean up the temp files I created for it as input.

    R 1 Reply Last reply
    0
    • D Dan Neely

      Process.WaitForExit() is a blocking call. Is there a nonblocking equivilant, or will I need to call the 2nd app from a thread. I need to know when it's finished so that I can clean up the temp files I created for it as input.

      R Offline
      R Offline
      Robin Panther
      wrote on last edited by
      #2

      You can handle Process.Exited event. like this: Process notepadProcess; private void button1_Click(object sender, EventArgs e) { notepadProcess = new Process(); notepadProcess.EnableRaisingEvents = true; // tell process to raise Exited event notepadProcess.Exited += new EventHandler(notepadProcess_Exited); // Exited event handler notepadProcess.StartInfo.FileName = "notepad.exe"; notepadProcess.Start(); } void notepadProcess_Exited(object sender, EventArgs e) { MessageBox.Show("Notepad process just has been exited."); notepadProcess.Dispose(); } Robin Panther http://www.robinland.com

      D 1 Reply Last reply
      0
      • R Robin Panther

        You can handle Process.Exited event. like this: Process notepadProcess; private void button1_Click(object sender, EventArgs e) { notepadProcess = new Process(); notepadProcess.EnableRaisingEvents = true; // tell process to raise Exited event notepadProcess.Exited += new EventHandler(notepadProcess_Exited); // Exited event handler notepadProcess.StartInfo.FileName = "notepad.exe"; notepadProcess.Start(); } void notepadProcess_Exited(object sender, EventArgs e) { MessageBox.Show("Notepad process just has been exited."); notepadProcess.Dispose(); } Robin Panther http://www.robinland.com

        D Offline
        D Offline
        Dan Neely
        wrote on last edited by
        #3

        Thanks. I figured there had to be a more graceful way to do it.

        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