[chronojump] All threads start/ending/ended goes to LogB now



commit 866d2e68876258b5df19b1f153f536dcc5fde64f
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Dec 31 12:07:06 2014 +0100

    All threads start/ending/ended goes to LogB now

 src/chronojump.cs             |    6 +++++-
 src/execute/event.cs          |   11 ++---------
 src/execute/jump.cs           |    7 ++++++-
 src/execute/multiChronopic.cs |    2 ++
 src/execute/pulse.cs          |    2 ++
 src/execute/reactionTime.cs   |    2 ++
 src/execute/run.cs            |    4 ++--
 src/gui/chronojump.cs         |    2 --
 src/gui/chronopic.cs          |    6 +++++-
 src/gui/encoder.cs            |   29 ++++++++++++++++++++++-------
 src/gui/preferences.cs        |    8 ++++++--
 src/logB.cs                   |   39 ++++++++++++++++++++++++++++++++++++---
 12 files changed, 90 insertions(+), 28 deletions(-)
---
diff --git a/src/chronojump.cs b/src/chronojump.cs
index 2042c8e..c2213f2 100644
--- a/src/chronojump.cs
+++ b/src/chronojump.cs
@@ -178,6 +178,7 @@ public class ChronoJump
 
                thread = new Thread(new ThreadStart(sqliteThings));
                GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
+               LogB.ThreadStart();
                thread.Start(); 
 
                Application.Run();
@@ -562,8 +563,11 @@ public class ChronoJump
 
                if( ( needEndSplashWin && pingEnd ) 
                                || ! thread.IsAlive) {
-                       fakeSplashButton.Click();
+                       LogB.ThreadEnding();
+                       fakeSplashButton.Click();
+
                        LogB.Information("splash window ending here");
+                       LogB.ThreadEnded();
                        return false;
                }
                //need to do this, if not it crashes because chronopicWin gets died by thread ending
diff --git a/src/execute/event.cs b/src/execute/event.cs
index 9f43846..caf3b9c 100644
--- a/src/execute/event.cs
+++ b/src/execute/event.cs
@@ -234,9 +234,10 @@ public class EventExecute
                //then thread is dead
 
                if ( ! thread.IsAlive || cancel) {
+                       LogB.ThreadEnding(); 
                        fakeButtonThreadDyed.Click();
-                       LogB.Information("dying");
 
+                       LogB.ThreadEnded(); 
                        return false;
                }
        
@@ -246,14 +247,6 @@ public class EventExecute
        }
 
 
-       public void StopThread() {
-               /*
-               Log.WriteLine("----------ABORTING----------");
-               thread.Abort();
-               Log.WriteLine("----------ABORTED-----------");
-               */
-       }
-
        protected void initializeTimer () {
                //put onTimer count to 0 for moving the time progressBar (activiy mode) 
                //also in simulated, allows to change platform state
diff --git a/src/execute/jump.cs b/src/execute/jump.cs
index 6e8b883..2b424d4 100644
--- a/src/execute/jump.cs
+++ b/src/execute/jump.cs
@@ -142,9 +142,10 @@ public class JumpExecute : EventExecute
                                platformState = Chronopic.Plataforma.OFF;
                        
                        //start thread
-                       //Log.Write("Start thread");
                        thread = new Thread(new ThreadStart(waitEvent));
                        GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
+                       
+                       LogB.ThreadStart(); 
                        thread.Start(); 
                } 
                else if (platformState==Chronopic.Plataforma.OFF) {
@@ -226,6 +227,8 @@ public class JumpExecute : EventExecute
                        //start thread
                        thread = new Thread(new ThreadStart(waitEvent));
                        GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
+                       
+                       LogB.ThreadStart(); 
                        thread.Start(); 
                } 
                else  
@@ -666,6 +669,8 @@ public class JumpRjExecute : JumpExecute
                        //start thread
                        thread = new Thread(new ThreadStart(waitEvent));
                        GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
+                       
+                       LogB.ThreadStart(); 
                        thread.Start(); 
                }
        }
diff --git a/src/execute/multiChronopic.cs b/src/execute/multiChronopic.cs
index c988bdb..85f10e6 100644
--- a/src/execute/multiChronopic.cs
+++ b/src/execute/multiChronopic.cs
@@ -347,7 +347,9 @@ public class MultiChronopicExecute : EventExecute
                        GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
 
                        if(chronopics > 0) {
+                               LogB.ThreadStart(); 
                                thread.Start(); 
+
                                if(chronopics > 1) {
                                        thread2.Start(); 
                                        if(chronopics > 2) {
diff --git a/src/execute/pulse.cs b/src/execute/pulse.cs
index 397cc0d..fbb1a7b 100644
--- a/src/execute/pulse.cs
+++ b/src/execute/pulse.cs
@@ -175,6 +175,8 @@ public class PulseExecute : EventExecute
                        //start thread
                        thread = new Thread(new ThreadStart(waitEvent));
                        GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
+               
+                       LogB.ThreadStart(); 
                        thread.Start(); 
                }
        }
diff --git a/src/execute/reactionTime.cs b/src/execute/reactionTime.cs
index c320ef1..db3f112 100644
--- a/src/execute/reactionTime.cs
+++ b/src/execute/reactionTime.cs
@@ -122,6 +122,8 @@ public class ReactionTimeExecute : EventExecute
                        //Log.Write("Start thread");
                        thread = new Thread(new ThreadStart(waitEvent));
                        GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
+                       
+                       LogB.ThreadStart(); 
                        thread.Start(); 
                } 
                else if (platformState==Chronopic.Plataforma.OFF) {
diff --git a/src/execute/run.cs b/src/execute/run.cs
index a0af667..5846292 100644
--- a/src/execute/run.cs
+++ b/src/execute/run.cs
@@ -176,12 +176,12 @@ public class RunExecute : EventExecute
                cancel = false;
                totallyCancelled = false;
 
-               LogB.Debug("MANAGE(2)!!!!");
                //start thread
                thread = new Thread(new ThreadStart(waitEvent));
                GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
+                       
+               LogB.ThreadStart(); 
                thread.Start(); 
-               LogB.Debug("MANAGE(3)!!!!");
        }
        
        protected override void waitEvent ()
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 94a2586..19dacbc 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -3820,8 +3820,6 @@ public partial class ChronoJumpWindow
                        //since 0.7.4.1 when test is done, treeview select it. action event button have to be 
shown 
                        showHideActionEventButtons(true, "JumpRj"); //show
 
-                       //currentEventExecute.StopThread();
-
                        if(createdStatsWin) {
                                showUpdateStatsAndHideData(true);
                        }
diff --git a/src/gui/chronopic.cs b/src/gui/chronopic.cs
index fceb073..a43b3fb 100644
--- a/src/gui/chronopic.cs
+++ b/src/gui/chronopic.cs
@@ -533,9 +533,11 @@ public class ChronopicWindow
        protected bool PulseGTK ()
        {
                if(needUpdateChronopicWin || ! thread.IsAlive) {
+                       LogB.ThreadEnding();
                        fakeConnectionButton.Click();
                        pulseEnd();
-                       LogB.Information("dying");
+
+                       LogB.ThreadEnded();
                        return false;
                }
                //need to do this, if not it crashes because chronopicConnectionWin gets died by thread ending
@@ -779,6 +781,8 @@ public class ChronopicWindow
                needUpdateChronopicWin = false;
                thread = new Thread(new ThreadStart(waitChronopicStart));
                GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
+
+               LogB.ThreadStart();
                thread.Start(); 
        }
 
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index ad4357e..b41b1ca 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -4348,7 +4348,7 @@ public partial class ChronoJumpWindow
                                        
                if(action == encoderActions.CAPTURE || action == encoderActions.CAPTURE_IM) {
                        //encoder_pulsebar_capture.Text = Catalog.GetString("Please, wait.");
-                       LogB.Information("CCCCCCCCCCCCCCC");
+                       LogB.Information("encoderThreadStart begins");
                        if( runEncoderCaptureCsharpCheckPort(chronopicWin.GetEncoderPort()) ) {
                                if(action == encoderActions.CAPTURE) {
                                        if(RInitialized == Constants.Status.UNSTARTED)
@@ -4401,8 +4401,10 @@ public partial class ChronoJumpWindow
                                hbox_encoder_capture_wait.Visible = false;
                                hbox_encoder_capture_doing.Visible = true;
 
-                               LogB.Information("DDDDDDDDDDDDDDD");
+                               LogB.Information("encoderThreadStart middle");
                                encoderButtonsSensitive(encoderSensEnum.PROCESSINGCAPTURE);
+
+                               LogB.ThreadStart();
                                encoderThread.Start(); 
                        } else {
                                new DialogMessage(Constants.MessageTypes.WARNING, 
@@ -4434,6 +4436,8 @@ public partial class ChronoJumpWindow
                                else // action == encoderActions.LOAD
                                        GLib.Idle.Add (new GLib.IdleHandler (pulseGTKEncoderLoad));
                                encoderButtonsSensitive(encoderSensEnum.PROCESSINGR);
+                               
+                               LogB.ThreadStart();
                                encoderThread.Start(); 
                        }
                } else { //encoderActions.ANALYZE
@@ -4452,6 +4456,7 @@ public partial class ChronoJumpWindow
                        button_encoder_analyze_table_save.Sensitive = false;
                        button_encoder_analyze_1RM_save.Sensitive = false;
 
+                       LogB.ThreadStart();
                        encoderThread.Start(); 
                }
        }
@@ -4515,8 +4520,10 @@ public partial class ChronoJumpWindow
        private bool pulseGTKEncoderCaptureAndCurves ()
        {
                if(! encoderThread.IsAlive || encoderProcessCancel) {
+                       LogB.ThreadEnding(); 
                        finishPulsebar(encoderActions.CURVES);
-                       LogB.Information("dying");
+                       
+                       LogB.ThreadEnded(); 
                        return false;
                }
                if(capturingCsharp == encoderCaptureProcess.CAPTURING) {
@@ -4557,8 +4564,10 @@ public partial class ChronoJumpWindow
        private bool pulseGTKEncoderCaptureIM ()
        {
                if(! encoderThread.IsAlive || encoderProcessCancel) {
+                       LogB.ThreadEnding(); 
                        finishPulsebar(encoderActions.CAPTURE_IM);
-                       LogB.Information("dying");
+                       
+                       LogB.ThreadEnded(); 
                        return false;
                }
                updatePulsebar(encoderActions.CAPTURE_IM); //activity on pulsebar
@@ -4573,12 +4582,14 @@ public partial class ChronoJumpWindow
        private bool pulseGTKEncoderCurves ()
        {
                if(! encoderThread.IsAlive || encoderProcessCancel) {
+                       LogB.ThreadEnding(); 
                        if(encoderProcessCancel){
                                UtilEncoder.CancelRScript = true;
                        }
 
                        finishPulsebar(encoderActions.CURVES);
-                       LogB.Information("dying");
+                       
+                       LogB.ThreadEnded(); 
                        return false;
                }
                updatePulsebar(encoderActions.CURVES); //activity on pulsebar
@@ -4590,12 +4601,14 @@ public partial class ChronoJumpWindow
        private bool pulseGTKEncoderLoad ()
        {
                if(! encoderThread.IsAlive || encoderProcessCancel) {
+                       LogB.ThreadEnding(); 
                        if(encoderProcessCancel){
                                UtilEncoder.CancelRScript = true;
                        }
 
                        finishPulsebar(encoderActions.LOAD);
-                       LogB.Debug("dying");
+                       
+                       LogB.ThreadEnded(); 
                        return false;
                }
                updatePulsebar(encoderActions.LOAD); //activity on pulsebar
@@ -4607,12 +4620,14 @@ public partial class ChronoJumpWindow
        private bool pulseGTKEncoderAnalyze ()
        {
                if(! encoderThread.IsAlive || encoderProcessCancel) {
+                       LogB.ThreadEnding(); 
                        if(encoderProcessCancel){
                                UtilEncoder.CancelRScript = true;
                        }
 
                        finishPulsebar(encoderActions.ANALYZE);
-                       LogB.Debug("dying");
+                       
+                       LogB.ThreadEnded(); 
                        return false;
                }
                updatePulsebar(encoderActions.ANALYZE); //activity on pulsebar
diff --git a/src/gui/preferences.cs b/src/gui/preferences.cs
index 2ead9bd..4b7b42c 100644
--- a/src/gui/preferences.cs
+++ b/src/gui/preferences.cs
@@ -471,6 +471,8 @@ public class PreferencesWindow {
                                                GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
                
                                                backup_doing_sensitive_start_end(true); 
+                                               
+                                               LogB.ThreadStart(); 
                                                thread.Start(); 
                                        } else {
                                                File.Copy(fileDB, fileCopy);
@@ -505,6 +507,8 @@ public class PreferencesWindow {
                                GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
                
                                backup_doing_sensitive_start_end(true); 
+                               
+                               LogB.ThreadStart(); 
                                thread.Start(); 
                        } else {
                                File.Delete(fileCopy);
@@ -527,10 +531,10 @@ public class PreferencesWindow {
        private bool PulseGTK ()
        {
                if ( ! thread.IsAlive ) {
-                       LogB.Information("dying");
-                       
+                       LogB.ThreadEnding();
                        endPulse();
 
+                       LogB.ThreadEnded();
                        return false;
                }
        
diff --git a/src/logB.cs b/src/logB.cs
index eb774ee..2393faf 100644
--- a/src/logB.cs
+++ b/src/logB.cs
@@ -58,7 +58,8 @@ public enum LogEntryType
        Warning,
        Error,
        Information,
-       SQL
+       SQL,
+       ThreadStart, ThreadEnding, ThreadEnded
 }
 
 public class LogEntry
@@ -137,11 +138,17 @@ public static class LogB
                                case LogEntryType.Information:
                                        ConsoleCrayon.ForegroundColor = ConsoleColor.Green;
                                        break;
+                               case LogEntryType.Debug:
+                                       ConsoleCrayon.ForegroundColor = ConsoleColor.Blue;
+                                       break;
                                case LogEntryType.SQL:
                                        ConsoleCrayon.ForegroundColor = ConsoleColor.Cyan;
                                        break;
-                               case LogEntryType.Debug:
-                                       ConsoleCrayon.ForegroundColor = ConsoleColor.Blue;
+                               case LogEntryType.ThreadStart:
+                               case LogEntryType.ThreadEnding:
+                               case LogEntryType.ThreadEnded:
+                                       ConsoleCrayon.ForegroundColor = ConsoleColor.DarkBlue;
+                                       ConsoleCrayon.BackgroundColor = ConsoleColor.Yellow;
                                        break;
                        }
 
@@ -181,6 +188,12 @@ public static class LogB
                                return "Info ";
                        case LogEntryType.SQL:
                                return "SQL ";
+                       case LogEntryType.ThreadStart:
+                               return "Thread Start -------------------------->";
+                       case LogEntryType.ThreadEnding:
+                               return " <.......................... Thread Ending";
+                       case LogEntryType.ThreadEnded:
+                               return " <-------------------------- Thread Ended";
                }
                return null;
        }
@@ -439,6 +452,26 @@ public static class LogB
 
 #endregion
 
+#region Public SQL Methods
+       
+       public static void ThreadStart()
+       {
+               Commit(LogEntryType.ThreadStart, null, null, false);
+       }
+
+       public static void ThreadEnding()
+       {
+               Commit(LogEntryType.ThreadEnding, null, null, false);
+       }
+
+       public static void ThreadEnded()
+       {
+               Commit(LogEntryType.ThreadEnded, null, null, false);
+       }
+
+
+#endregion
+
 #region Public Exception Methods
 
        public static void DebugException(Exception e)


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