/// <summary> /// Ensure that a task source for the output pane is created. If it is the first task source output, make it the visible task source output. /// </summary> /// <param name="tasksource">Name of the task source.</param> /// <param name="executingTask">The currently executing task.</param> /// <param name="executingTask">The executer the currently executing task is running in.</param> /// <returns>The existing or newly created task source output.</returns> internal TaskSourceOutput EnsureTaskSourceOutputForExecutingTask(string tasksource, Process executingProcess, Executer executer) { bool makeVisible = false; TaskSourceOutput tso; if (CurrentTaskSourceOutput == null) { makeVisible = true; } // Get TaskSource output tso = GetTaskSourceOutput(tasksource); if (tso == null) { tso = new TaskSourceOutput { TaskSource = tasksource, ExecutingProcess = executingProcess, ProcessExecuter = executer, Output = String.Empty }; _taskSourceOutputs.Add(tso); } else { tso.ExecutingProcess = executingProcess; tso.ProcessExecuter = executer; } if (makeVisible) { CurrentTaskSourceOutput = tso; WebMatrixContext.OutputPaneInstance.Show(tasksource); } return tso; }
/// <summary> /// The constructor requires a reference to the process that will be read. /// The process should have .RedirectStandardOutput and .RedirectStandardError set to true. /// </summary> /// <param name="tasksource">Unique name of the executing task.</param> /// <param name="process">The process that will have its output read by this class.</param> /// <param name="worker"></param> public ProcessOutputHandler(string tasksource, Executer executer, System.Diagnostics.Process process) { _tasksource = tasksource; _executer = executer; _proc = process; Debug.Assert(_proc.StartInfo.RedirectStandardError, "RedirectStandardError must be true to use ProcessOutputHandler."); Debug.Assert(_proc.StartInfo.RedirectStandardOutput, "RedirectStandardOut must be true to use ProcessOutputHandler."); }