Search code examples
c#process.start

Detect if launched process has been closed


c# I want to Detect if a launched program has been closed. I am currently launching it with the command

 Process.Start(Environment.CurrentDirectory + @"\Card Downloader.exe"); 

Has anyone got a way of doing this perhaps using a different launcher?


Solution

  • The Process.Start() method returns a Process object. Assign it to a variable and call WaitForExit() on.

    Source: http://msdn.microsoft.com/en-us/library/fb4aw7b8.aspx

    Process process = Process.Start("notepad");
    process.WaitForExit();