Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restart a process

Tags:

c#

process

kill

I want to restart a program.
I've found the process and have called Kill method, then i've runned it again:
process.Kill();
process.Start();

It stops but doesn't start.
Also if I put Exited event it never fires.
What's the problem?

like image 515
Mehrdad Avatar asked Feb 19 '23 14:02

Mehrdad


1 Answers

Process.Kill() is asynchronous. You need to call Process.WaitForExit() after calling kill.

like image 178
gregwhitaker Avatar answered Feb 21 '23 03:02

gregwhitaker