/// <summary> /// Tries to terminate all running client processes because otherwise the /// client executable cannot be replaced by a newer version. /// </summary> private void StopClientProcesses() { try { Process [] ClientProcesses = Process.GetProcessesByName("CrawlWave.Client"); if (ClientProcesses.Length == 0) { //there are no client processes running return; } else //try to terminate each process { foreach (Process ClientProcess in ClientProcesses) { try { //First try to terminate it by closing its main window. ClientProcess.CloseMainWindow(); if (ClientProcess.HasExited) { //attempt to terminate the gui was successful ClientProcess.Close(); } else { //The Client is running in quiet mode, so we must kill it //TODO: Use the remoting interface of the Client in order //to stop it and then terminate its process. ClientProcess.Kill(); } } catch (Exception e) { if (globals.Settings.LogLevel <= CWLogLevel.LogWarning) { globals.SystemLog.LogWarning("CrawlWave.Client Scheduler failed to terminate all the client processes: " + e.ToString()); } continue; //try to terminate the rest of the processes. } } } } catch (Exception e) { if (globals.Settings.LogLevel <= CWLogLevel.LogWarning) { globals.SystemLog.LogWarning("CrawlWave.Client Scheduler encountered an error while stoping the client processes:" + e.ToString()); } } }