예제 #1
0
파일: Job.cs 프로젝트: Anders-H/JobRunner
        private void InProcess(IGridVisualFeedback grid, IVariableList variableList)
        {
            var inProcessJobIdentifyerHelper = new InProcessJobIdentifyerHelper();
            var jobId = inProcessJobIdentifyerHelper.GetIdentifyerFromString(Command);
            var job   = inProcessJobIdentifyerHelper.GetJob(jobId);
            var args  = new ArgumentList(Arguments);

            args = args.Decode(variableList);
            job.Begin(args);
            while (!job.HasExited)
            {
                grid.CursorBlink = !grid.CursorBlink;
                grid.Invalidate();
                Thread.Sleep(1000);
                if (DateTime.Now.Subtract(StartTime !.Value) <= Timeout)
                {
                    continue;
                }
                EndTime     = DateTime.Now;
                Status      = JobStatus.Timeout;
                FailMessage = "Timeout";
                ExitCode    = -1;
                return;
            }
            ExitCode = job.ExitCode;
            Status   = ExitCode == 0
                ? JobStatus.Completed
                : JobStatus.Failed;
            if (Status == JobStatus.Failed && job.Exception != null)
            {
                FailMessage = job.Exception.Message;
            }
        }