Thanks for your help. After taking a look at the information provided I got it.
Z
Zundee
@Zundee
Posts
-
Question on shutting down another program and wating for it to exit. -
Question on shutting down another program and wating for it to exit.Forgive my newbie question. I am trying to learn C#. I have utterly confused myself in trying to restart a server console. I do not have the server start on this yet but it locks up every time I restart and I am not real sure way. It shutsdown ok but then never makes the check if the process has exited. Can anyone give me a nudge in the right direction? Thanks
public void restartserver(string serverrs, string serverloc) { Process p = Process.GetCurrentProcess(); Process\[\] servername = Process.GetProcessesByName(serverrs); IntPtr serverHandle = FindWindow(null, serverloc); if (serverHandle == IntPtr.Zero) { if (serverrs == "arcemu-world") { btnWorldStatus.Text = "World Server is not running"; } else { btnLogonStatus.Text = "Logon Server is not running"; } } else { SetForegroundWindow(serverHandle); SendKeys.SendWait("Shutdown{ENTER}"); FreeConsole(); bool mytrue = true; while (mytrue) { if (p.HasExited) { mytrue = false; if (serverrs == "arcemu-world") { btnWorldStatus.Text = "Closing...."; } else { btnLogonStatus.Text = "Closing...."; } } } } }