[chronojump] At run, if it get hung on WAITING 100 MS TO EXIT BUCLE, exit at checkDoubleContactTime * 1.5



commit da1a4c7a99b0901bffba768476059b8fc59de49b
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Apr 28 17:41:46 2022 +0200

    At run, if it get hung on WAITING 100 MS TO EXIT BUCLE, exit at checkDoubleContactTime * 1.5

 src/execute/run.cs | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/src/execute/run.cs b/src/execute/run.cs
index a682136a4..963f8bc0e 100644
--- a/src/execute/run.cs
+++ b/src/execute/run.cs
@@ -570,13 +570,23 @@ LogB.Information("going to call photocellWirelessCapture.CaptureStart ()");
                if(runDC.UseDoubleContacts())
                {
                        LogB.Information(string.Format("success: {0}, cancel: {1}, finish: {2}", success, 
cancel, finish));
-                       while(needCheckIfTrackEnded)
+
+                       //to avoid get hung waiting needCheckIfTrackEnded
+                       DateTime started = DateTime.Now;
+                       TimeSpan span = DateTime.Now - started;
+
+                       while(needCheckIfTrackEnded && span.TotalMilliseconds < checkDoubleContactTime * 1.5)
                        {
                                LogB.Information("WAITING 100 MS TO EXIT BUCLE");
                                //TODO: checks what happens with cancel... in the pulse thread, will change 
this boolean? needCheckIfTrackEnded
                                //TODO: also think on what happens if needCheckIfTrackEnded never gets 
negative
                                Thread.Sleep(100);
+                               span = DateTime.Now - started;
                        }
+                       if(! needCheckIfTrackEnded)
+                               LogB.Information("Exited 100 MS BUCLE because needCheckIfTrackEnded is 
false");
+                       else
+                               LogB.Information("Exited 100 MS BUCLE because time exceded");
 
                        return true;
                }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]