Ejemplo n.º 1
0
 public void Close()
 {
     BackgroundThreadContinue = false;
     BackgroundThread.Interrupt();
     BackgroundThread.Abort();
     BackgroundThread.Join();
     Send("Have a nice day!");
     ClientSocket.Close();
     ClientProcess.Close();
     OnExited(this);
 }
Ejemplo n.º 2
0
 /// <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());
         }
     }
 }