Пример #1
0
        protected ExecMonitor RunProcess(ProcessStartInfo psi, IOutput output, Action <string, IOutput> write)
        {
            var prc = new Process {
                StartInfo = psi
            };

            if (Properties?.CaptureOutput ?? false)
            {
                prc.ErrorDataReceived  += (o, e) => write(e.Data, output);
                prc.OutputDataReceived += (o, e) => write(e.Data, output);
            }

            var monitor = new ExecMonitor(
                () => RunProcess(prc, output, write),
                () => KillProcess(prc)
                );

            return(monitor);
        }
Пример #2
0
        private void InternalRun()
        {
            running = true;
            Write($"Task {Name}");
            var errors = 0;
            var idx    = 0;

            foreach (var s in Steps)
            {
                if (s.Properties != null && DefaultProperties != null)
                {
                    s.Properties = s.Properties.MergeWith(DefaultProperties);
                }
                else if (DefaultProperties != null)
                {
                    s.Properties = DefaultProperties.Clone();
                }

                Write($"{++idx}. Step {s.Name}");

                var res = false;
                currentStep = s.Start(Output);
                var tt = TT.Task.Run(() => res = currentStep.Wait());
                tt.Wait();

                if (!res)
                {
                    errors++;
                }

                if (!res && Behavior == TaskBehavior.FailFirst)
                {
                    Write($"Task terminated ({Behavior}).");
                    break;
                }
            }

            Write($"Task completed. Errors: {errors}. Passed: {Steps.Count-errors}");
            running = false;
        }