[chronojump] Better method to know if a process is alive (isRunning2)
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Better method to know if a process is alive (isRunning2)
- Date: Wed, 1 Aug 2018 14:02:10 +0000 (UTC)
commit d13982190f14fa99ba2fec0fc4c69d5ccd31f82a
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Aug 1 16:01:22 2018 +0200
Better method to know if a process is alive (isRunning2)
src/executeProcess.cs | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/src/executeProcess.cs b/src/executeProcess.cs
index bedba294..a879ee52 100644
--- a/src/executeProcess.cs
+++ b/src/executeProcess.cs
@@ -179,14 +179,31 @@ class ExecuteProcess
return true;
}
- public static bool IsRunning(Process p)
+
+ //better method than below
+ //https://stackoverflow.com/a/262291
+ public static bool IsRunning2 (Process process, string executable)
+ {
+ Process[] pNameArray = Process.GetProcessesByName("ffmpeg");
+ if (pNameArray.Length == 0)
+ return false;
+
+ foreach(Process p in pNameArray)
+ if(p.Id == process.Id)
+ return true;
+
+ return false;
+ }
+
+ //This seems is not working with ffmpeg capture, try method obove
+ public static bool IsRunning(Process process)
{
LogB.Debug("calling Process.IsRunning()");
- if(p == null) {
- LogB.Debug("p == null");
+ if(process == null) {
+ LogB.Debug("process == null");
return false;
} else {
- if(isRunningThisProcess(p))
+ if(isRunningThisProcess(process))
return true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]