fixed NzbDrone using 100% cpu when console not available.

This commit is contained in:
Keivan Beigi 2013-08-20 15:12:35 -07:00
commit 75a46a3abe
9 changed files with 39 additions and 31 deletions

View file

@ -21,6 +21,7 @@ namespace NzbDrone.Common
bool Exists(string processName);
ProcessPriorityClass GetCurrentProcessPriority();
Process Start(string path, string args = null, Action<string> onOutputDataReceived = null, Action<string> onErrorDataReceived = null);
Process SpawnNewProcess(string path, string args = null);
}
public class ProcessProvider : IProcessProvider
@ -86,6 +87,8 @@ namespace NzbDrone.Common
process.Start();
}
public Process Start(string path, string args = null, Action<string> onOutputDataReceived = null, Action<string> onErrorDataReceived = null)
{
@ -147,6 +150,27 @@ namespace NzbDrone.Common
return process;
}
public Process SpawnNewProcess(string path, string args = null)
{
if (OsInfo.IsMono && path.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase))
{
args = path + " " + args;
path = "mono";
}
Logger.Info("Starting {0} {1}", path, args);
var startInfo = new ProcessStartInfo(path, args);
var process = new Process
{
StartInfo = startInfo
};
process.Start();
return process;
}
public void WaitForExit(Process process)
{
Logger.Trace("Waiting for process {0} to exit.", process.ProcessName);