コード例 #1
0
 public ConsoleProcessAsynchronousHandle(string strFilePath, string strArguments, int intTimeOut, ConsoleProcessResultInterpreter objInterpreter)
 {
     TimeOut     = intTimeOut;
     FilePath    = strFilePath;
     Arguments   = strArguments;
     Interpreter = objInterpreter;
     HandleUid   = Guid.NewGuid().ToString();
     Cancelled   = false;
 }
コード例 #2
0
 public ConsoleProcessResult(string strFilePath, string strArguments, ConsoleProcessResultType enuProcessResult, int intExitCode, IEnumerable <string> objOutputLines, ConsoleProcessResultInterpreter objInterpreter)
 {
     FilePath         = strFilePath;
     Arguments        = strArguments;
     ProcessResult    = enuProcessResult;
     ExitCode         = intExitCode;
     ProcessException = null;
     Interpreter      = objInterpreter;
     _objOutputLines  = new List <string>(objOutputLines);
 }
コード例 #3
0
 public ConsoleProcessAsynchronousHandle(string strFilePath, int intTimeOut, ConsoleProcessResultInterpreter objInterpreter)
     : this(strFilePath, string.Empty, intTimeOut, objInterpreter)
 {
 }
コード例 #4
0
 public ConsoleProcessAsynchronousHandle(string strFilePath, string strArguments, ConsoleProcessResultInterpreter objInterpreter)
     : this(strFilePath, strArguments, ConsoleProcess.DefaultTimeOut, objInterpreter)
 {
 }
コード例 #5
0
        public ConsoleProcessResult ExecuteSynchronous(string strFilePath, string strArguments, int intTimeOut, ConsoleProcessResultInterpreter objInterpreter)
        {
            ConsoleProcessResult objResult = null;

            ProcessStartInfo objStartInfo = CreateProcessStartInfo(strFilePath, strArguments);

            try
            {
                using (Process objProcess = Process.Start(objStartInfo))
                {
                    bool blnResult = objProcess.WaitForExit(intTimeOut * 1000);
                    if (blnResult == true)
                    {
                        string        strOutputLine;
                        List <string> objOutputLines = new List <string>();
                        while ((strOutputLine = objProcess.StandardOutput.ReadLine()) != null)
                        {
                            objOutputLines.Add(strOutputLine);
                        }

                        objResult = new ConsoleProcessResult(strFilePath, strArguments, ConsoleProcessResultType.Completed, objProcess.ExitCode, objOutputLines, objInterpreter);
                    }
                    else
                    {
                        objResult = new ConsoleProcessResult(strFilePath, strArguments, ConsoleProcessResultType.TimedOut, -1, objInterpreter);
                    }
                }
            }
            catch (Exception objException)
            {
                objResult = new ConsoleProcessResult(strFilePath, strArguments, objException, objInterpreter);
            }

            return(objResult);
        }
コード例 #6
0
 public ConsoleProcessResult ExecuteSynchronous(string strFilePath, string strArguments, ConsoleProcessResultInterpreter objInterpreter)
 {
     return(ExecuteSynchronous(strFilePath, strArguments, DefaultTimeOut, objInterpreter));
 }
コード例 #7
0
 public ConsoleProcessResult ExecuteSynchronous(string strFilePath, int intTimeOut, ConsoleProcessResultInterpreter objInterpreter)
 {
     return(ExecuteSynchronous(strFilePath, string.Empty, intTimeOut, objInterpreter));
 }
コード例 #8
0
        public ConsoleProcessAsynchronousHandle ExecuteAsynchronous(string strFilePath, string strArguments, int intTimeOut, ConsoleProcessResultInterpreter objInterpreter)
        {
            ParameterizedThreadStart objParameterizedThreadStart = new ParameterizedThreadStart(ExecuteAsynchronousProc);
            Thread objExecuteAsynchronousThread = new Thread(objParameterizedThreadStart);

            objExecuteAsynchronousThread.IsBackground = true;

            ConsoleProcessAsynchronousHandle objHandle = new ConsoleProcessAsynchronousHandle(strFilePath, strArguments, intTimeOut, objInterpreter);

            objExecuteAsynchronousThread.Start(objHandle);

            return(objHandle);
        }
コード例 #9
0
 public ConsoleProcessAsynchronousHandle ExecuteAsynchronous(string strFilePath, ConsoleProcessResultInterpreter objInterpreter)
 {
     return(ExecuteAsynchronous(strFilePath, string.Empty, DefaultTimeOut, objInterpreter));
 }
コード例 #10
0
 public ConsoleProcessResult(string strFilePath, string strArguments, ConsoleProcessResultType enuProcessResult, int intExitCode, ConsoleProcessResultInterpreter objInterpreter)
     : this(strFilePath, strArguments, enuProcessResult, intExitCode, new string[] {}, objInterpreter)
 {
 }
コード例 #11
0
 public ConsoleProcessResult(string strFilePath, string strArguments, Exception objProcessException, ConsoleProcessResultInterpreter objInterpreter)
     : this(strFilePath, strArguments, ConsoleProcessResultType.Failed, -1, new string[] {}, objInterpreter)
 {
     ProcessException = objProcessException;
 }