Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Process WaitForExit()

Tags:

c#

I use the below statements in my application:

System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = 'FileName';
process.Start();
process.WaitForExit(900000); // 15 minutes

How does it work? After 15 minutes, if the 'FileName' is still running/executing, will process.WaitForExit(900000); kill the process? Else the execution goes to the next statement without killing the 'FileName', i.e. 'FileName' continue to run till it's execution completed?

like image 780
Govinth Avatar asked Jul 19 '26 14:07

Govinth


2 Answers

Yes, if a time-limited WaitForExit returns due to the limit being elapsed the process continues to run.

like image 197
Jon Avatar answered Jul 21 '26 02:07

Jon


You could try

Process.CloseMainWindow();

this will close the main window of your application and therefore end it smoothly.

like image 23
bytecode77 Avatar answered Jul 21 '26 02:07

bytecode77



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!