Example #1
0
 /// <summary>
 /// 
 /// </summary>
 private void StartPythonEngine()
 {
     #region ----------   TRY-CATCH   ----------
     try
     {
         
         // Start python engine
         pythonEngineProcess = new Process();
         pythonEngineProcess.StartInfo.FileName = PythonEngine;
         pythonEngineProcess.StartInfo.Arguments = PythonStartFile +" " + Properties.Settings.Default.ClientPort;
         pythonEngineProcess.StartInfo.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory;
    //     pythonEngineProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
         pythonEngineProcess.Start();
         pythonListener = new PythonHandler(this);                
     }
     catch (Win32Exception e)
     {
         EndProcess(e);
     }
     catch (ObjectDisposedException e)
     {
         EndProcess(e);
     }
     catch (InvalidOperationException e)
     {
         EndProcess(e);
     }
     catch (Exception e)
     {
         EndProcess(e);
     }
     #endregion
 }
Example #2
0
 public void StopPythonEngine()
 {
     #region ----------   TRY-CATCH   ----------
     try
     {
         if (pythonEngineProcess != null)
         {
             pythonEngineProcess.Kill();
             pythonEngineProcess.Dispose();
             pythonEngineProcess = null;
         }
         if (pythonListener != null)
         {
             pythonListener.Close();
             pythonListener = null;
         }
     }
     catch (Win32Exception e)
     {
         PrintToLog(e.Message, Color.Red);
         pythonEngineProcess = null;
         pythonListener = null;
     }
     catch (InvalidOperationException e)
     {
         PrintToLog(e.Message, Color.Red);
         pythonEngineProcess = null;
         pythonListener = null;
     }
     catch (Exception e)
     {
         PrintToLog(e.Message, Color.Red);
         pythonEngineProcess = null;
         pythonListener = null;
     }
     #endregion
 }