[chronojump] better p.ID checking
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] better p.ID checking
- Date: Sun, 7 Aug 2016 14:40:21 +0000 (UTC)
commit 9e682d3705159fdb5da7d524f799038f216c8895
Author: Xavier de Blas <xaviblas gmail com>
Date: Sun Aug 7 16:32:43 2016 +0200
better p.ID checking
src/encoderRProc.cs | 27 +++++++++++----------------
1 files changed, 11 insertions(+), 16 deletions(-)
---
diff --git a/src/encoderRProc.cs b/src/encoderRProc.cs
index 281c736..20bbbdc 100644
--- a/src/encoderRProc.cs
+++ b/src/encoderRProc.cs
@@ -68,29 +68,24 @@ public abstract class EncoderRProc
if(p == null) {
LogB.Debug("p == null");
return false;
+ } else {
+ if(isRunningThisProcess(p))
+ return true;
}
-
- /*
- LogB.Debug("print processes");
- Process [] pids = Process.GetProcesses();
- foreach (Process myPid in pids)
- LogB.Information(myPid.ToString());
- */
-
- LogB.Debug(string.Format("last pid id {0}", p.Id));
-
-
- //if(isRunningThisProcess("Rscript") || isRunningThisProcess("*R*"))
- if(isRunningThisProcess(p.Id))
- return true;
return false;
}
- private bool isRunningThisProcess(int id)
+ private bool isRunningThisProcess(Process p)
{
+ /*
+ * Process Id is not valid if the associated process is not running.
+ * Need to ensure that the process is running before attempting to retrieve the Id property.
+ */
+
try {
- Process pid = Process.GetProcessById(id);
+ LogB.Debug(string.Format("last pid id {0}", p.Id));
+ Process pid = Process.GetProcessById(p.Id);
if(pid == null)
return false;
} catch {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]