private void Run() { NotifyStarted(); mCancellationToken.ThrowIfCancellationRequested(); List <string> commandLines = ExpandCommandLines(); BatchEvaluationCompetitor competitor = mCompetitor; var terminalProcess = Process.Start(new ProcessStartInfo("cmd.exe") { WorkingDirectory = competitor.Directory, RedirectStandardInput = true, CreateNoWindow = true, UseShellExecute = false }); foreach (string line in commandLines) { mCancellationToken.ThrowIfCancellationRequested(); //terminalProcess.StandardInput.WriteLine(line); Process cmdProc = new Process() { StartInfo = new ProcessStartInfo("cmd.exe") { Arguments = $"/c {line}", WorkingDirectory = competitor.Directory, UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true }, EnableRaisingEvents = true }; cmdProc.OutputDataReceived += ((s, e) => { }); cmdProc.ErrorDataReceived += ((s, e) => { }); cmdProc.Start(); cmdProc.WaitForExit((int)TimeSpan.FromSeconds(10).TotalMilliseconds); if (!cmdProc.HasExited) { cmdProc.Kill(); } Notify(CommandRan, new CommandRanEventArgs { CommandLine = line, Competitor = competitor }); } terminalProcess.StandardInput.Close(); try { terminalProcess.Kill(); } catch { } }
public CommandLineRunningTask( Action <Delegate, object[]> eventDispatcher, CancellationToken cancellationToken, IReadOnlyList <string> commandLineTemplates, IReadOnlyList <BatchEvaluationProblem> problems, BatchEvaluationCompetitor competitor ) : base(eventDispatcher, cancellationToken) { mCommandLineTemplates = commandLineTemplates; mProblems = problems; mCompetitor = competitor; }
public BatchEvaluationSolutionGraderTask( Action <Delegate, object[]> eventDispatcher, CancellationToken cancellationToken, BatchEvaluationCompetitor competitor, BatchEvaluationProblem problem, IReadOnlyList <SolutionEvaluationTestResult> testResults ) : base(eventDispatcher, cancellationToken) { mTestResults = testResults; mCompetitor = competitor; mProblem = problem; }
private void RunCompetitor(BatchEvaluationCompetitor competitor) { mCancellationToken.ThrowIfCancellationRequested(); var competitorTask = new CompetitorEvaluationTask( eventDispatcher: null, cancellationToken: mCancellationToken, competitor: competitor, problems: mProblems, commandLineTemplates: mCommandLineTemplates ); competitorTask.CommandRan += HandleCommandLineRan; competitorTask.TestEvaluated += CompetitorTask_TestEvaluated; competitorTask.SolutionGraded += CompetitorTask_SolutionGraded; competitorTask.Start(); competitorTask.ExecutingTask.Wait(); }