diff options
author | sr55 <[email protected]> | 2009-01-23 21:08:28 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2009-01-23 21:08:28 +0000 |
commit | e98a23579ed5e4ca68d9c82af3ac50dfd833e86e (patch) | |
tree | d016ac9c57c3190a4f1881e3f747600b6d93bfc2 /win/C#/Functions/Main.cs | |
parent | 041ee4d8203087656775caecb5a312f246bdc2ae (diff) |
WinGui:
- Few more bits of code refactored.
- Added a 10 second limit for the CLI to respond at GUI startup. This will prevent the app from locking if the CLI stalls.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2093 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/Functions/Main.cs')
-rw-r--r-- | win/C#/Functions/Main.cs | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/win/C#/Functions/Main.cs b/win/C#/Functions/Main.cs index 05bb00f56..af0ce7f72 100644 --- a/win/C#/Functions/Main.cs +++ b/win/C#/Functions/Main.cs @@ -173,7 +173,7 @@ namespace Handbrake.Functions data_chpt.Rows[n].Cells[1].ValueType = typeof(string);
i++;
}
-
+
return data_chpt;
}
@@ -324,7 +324,7 @@ namespace Handbrake.Functions if (line == null) line = "";
Match m = Regex.Match(line, @"HandBrake ([0-9\.]*)*(svn[0-9]*[M]*)* \([0-9]*\)");
- if (m.Success != false)
+ if (m.Success)
{
string data = line.Replace("(", "").Replace(")", "").Replace("HandBrake ", "");
string[] arr = data.Split(' ');
@@ -332,6 +332,9 @@ namespace Handbrake.Functions cliVersionData.Add(arr[1]);
return cliVersionData;
}
+ if (cliProcess.TotalProcessorTime.Seconds > 10) // Don't wait longer than 10 seconds.
+ killCLI();
+
}
}
catch (Exception e)
@@ -343,6 +346,22 @@ namespace Handbrake.Functions cliVersionData.Add("0");
return cliVersionData;
}
+ private void killCLI()
+ {
+ string AppName = "HandBrakeCLI";
+ AppName = AppName.ToUpper();
+
+ System.Diagnostics.Process[] prs = Process.GetProcesses();
+ foreach (System.Diagnostics.Process proces in prs)
+ {
+ if (proces.ProcessName.ToUpper() == AppName)
+ {
+ proces.Refresh();
+ if (!proces.HasExited)
+ proces.Kill();
+ }
+ }
+ }
/// <summary>
/// Check if the queue recovery file contains records.
|