private void DisposeCurrentExecution() { _currentRuntimeExecution.StandardOutputAvailable -= CurrentRuntimeExecution_StandardOutputAvailable; _currentRuntimeExecution.StandardErrorAvailable -= CurrentRuntimeExecution_StandardErrorAvailable; _currentRuntimeExecution.Completed -= CurrentRuntimeExecution_Completed; _currentRuntimeExecution.Faulted -= CurrentRuntimeExecution_Faulted; _currentRuntimeExecution.Dispose(); _currentRuntimeExecution = null; }
public void Start(string scriptPath, string workingDirectory) { if (_currentRuntimeExecution != null) { throw new InvalidOperationException("Only one execution per runtime is allowed."); } // TODO: need to support starting with more arguments string args = scriptPath; // create the execution wrapper _currentRuntimeExecution = new ExternalProcess(_runtimeExecutablePath, args, workingDirectory); // subscribe to all of the events _currentRuntimeExecution.StandardOutputAvailable += CurrentRuntimeExecution_StandardOutputAvailable; _currentRuntimeExecution.StandardErrorAvailable += CurrentRuntimeExecution_StandardErrorAvailable; _currentRuntimeExecution.Completed += CurrentRuntimeExecution_Completed; _currentRuntimeExecution.Faulted += CurrentRuntimeExecution_Faulted; // start execution of the runtime _currentRuntimeExecution.Start(); }