#region Copyright 2010-2014 by Roger Knapp, Licensed under the Apache License, Version 2.0
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#endregion
using System;
using System.IO;
namespace CSharpTest.Net.Processes
{
///
/// The common interface between spawning processes, and spawning scripts.
///
public interface IRunner : IDisposable
{
/// Notifies caller of writes to the std::err or std::out
event ProcessOutputEventHandler OutputReceived;
/// Notifies caller when the process exits
event ProcessExitedEventHandler ProcessExited;
/// Allows writes to the std::in for the process
System.IO.TextWriter StandardInput { get; }
/// Waits for the process to exit and returns the exit code
int ExitCode { get; }
/// Returns true if this instance is running a process
bool IsRunning { get; }
/// Kills the process if it is still running
void Kill();
/// Closes std::in and waits for the process to exit
void WaitForExit();
/// Closes std::in and waits for the process to exit, returns false if the process did not exit in the time given
bool WaitForExit(TimeSpan timeout);
/// Gets or sets the initial working directory for the process.
string WorkingDirectory { get; set; }
/// Runs the process and returns the exit code.
int Run();
/// Runs the process and returns the exit code.
int Run(params string[] args);
/// Runs the process and returns the exit code.
int Run(TextReader input, params string[] arguments);
/// Starts the process and returns.
void Start();
/// Starts the process and returns.
void Start(params string[] args);
}
}