コード例 #1
0
        private bool RunOperation(OperationBase operation)
        {
            if (operation == null)
            {
                return(false);
            }

            try
            {
                if (!operation.IsProcessCreated)
                {
                    operation.CreateProcess();
                }

                _logger?.Info($"Starting {operation.Name}.");
                var isStarted = operation.Process?.Start();


                var b = !isStarted;
                if (b != null && (bool)b)
                {
                    _logger?.Error($"The operation {operation.Name} did not start successfully.");
                    Kill(operation);
                    return(false);
                }

                if (operation.Process != null)
                {
                    operation.Process?.BeginOutputReadLine();
                    operation.Process?.BeginErrorReadLine();
                }
            }
            catch (Exception e)
            {
                _logger?.Error(e);
                return(false);
                //throwing here will kill the app, just move on to next operation, error is logged...
            }
            return(true);
        }