[chronojump] Better cancelling with static method and variable



commit 25238f07c564cd0996bc4ce6e293c63f9b2ec778
Author: Xavier de Blas <xaviblas gmail com>
Date:   Sun Nov 20 11:43:57 2016 +0100

    Better cancelling with static method and variable

 src/chronopic.cs      |   13 +++++++++----
 src/gui/chronojump.cs |    4 ++--
 2 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/src/chronopic.cs b/src/chronopic.cs
index 53b200b..b385bec 100644
--- a/src/chronopic.cs
+++ b/src/chronopic.cs
@@ -306,7 +306,7 @@ public class Chronopic {
                //-- esperados para la trama. (En el caso de id son 4). Si hay un 
                //-- timeout se aborta
                count=0;
-               CancelDo = false;
+               cancellingTest = false;
                do {
                        //try, catch done because mono-1.2.3 throws an exception when there's a timeout
                        //http://bugzilla.gnome.org/show_bug.cgi?id=420520
@@ -320,8 +320,8 @@ public class Chronopic {
                                        success = true;
                                } catch {
                                        //LogB.Warning("catched at Read_cambio");
-                                       //if cancel is clicked, CancelDo will be true. Stop reading
-                                       if(CancelDo)
+                                       //if cancel is clicked, cancellingTest will be true. Stop reading
+                                       if(cancellingTest)
                                        {
                                                //-- Wait a bit and empty buffer
                                                Thread.Sleep(ErrorTimeout);
@@ -359,7 +359,12 @@ public class Chronopic {
 
        public bool AbortFlush; 
 
-       public bool CancelDo;
+       //Used by two threads
+       private static bool cancellingTest;
+       public static void CancelDo()
+       {
+               cancellingTest = true;
+       }
 
        //-- Vaciar buffer de entrada
        //-- De momento se hace leyendo muchos datos y descartando
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index a5acc11..8f95170 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -3452,7 +3452,7 @@ public partial class ChronoJumpWindow
                currentEventExecute.Cancel = true;
 
                //this will actually cancel Read_cambio and then Read_event in order to really cancel
-               cp2016.CP.CancelDo = true;
+               Chronopic.CancelDo();
 
                //if(cp2016.StoredCanCaptureContacts)
                //      checkCancelTotally(o, args);
@@ -3476,7 +3476,7 @@ public partial class ChronoJumpWindow
                currentEventExecute.Cancel = true;
 
                //this will actually cancel Read_cambio and then Read_event in order to really cancel
-               cp2016.CP.CancelDo = true;
+               Chronopic.CancelDo();
 
                //if(cp2016.StoredCanCaptureContacts)
                //      checkCancelMultiTotally(o, args);


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