Inheritance: IDisposable
Ejemplo n.º 1
0
    //Render thread entry point
    public void Run()
    {
      SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler(this.SystemEvents_PowerModeChanged);
      bool flag2 = false;
      Settings.Instance.LogInfo("MiniDisplay.Run(): Entering MiniDisplay run loop.");
      try
      {
        Settings.Instance.LogInfo("MiniDisplay.Run(): Creating MiniDisplay displayhandler.");
        this.handler = new DisplayHandler(this.display);
        Settings.Instance.LogInfo("MiniDisplay.Run(): Starting MiniDisplay displayhandler.");
        this.handler.Start();
        while (!this.stopRequested)
        {
          if (!Settings.Instance.Type.Equals("MCEDisplay"))
          {
            try
            {
              // It's not safe to call this method in other states than running, since
              // it calls the window manager. It might cause a dead lock in other states
              if (GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.RUNNING)
              {
                DoWork();
              }
            }
            catch (Exception exception)
            {
              Log.Debug("MiniDisplay.Run(): CAUGHT EXCEPTION in DoWork() - {0}", exception);
              if (exception.Message.Contains("ThreadAbortException"))
              {
                this.stopRequested = true;
              }
            }
            try
            {
                // It's not safe to call this method in other states than running, since
                // it calls the window manager. It might cause a dead lock in other states
                if (GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.RUNNING)
                {
                    //Is it time for us to scroll our texts?                    
                    if ((DateTime.Now - this.lastScroll).TotalMilliseconds >= Settings.Instance.ScrollDelay)
                    {
                        this.lastScroll = DateTime.Now; //Mark the time
                        //Take care of scrolling our texts
                        handler.DisplayLines();
                    }

                    //Do update regardless of whether or not we scrolled our texts
                    handler.Update();
                }
            }
            catch (Exception exception2)
            {
              Log.Debug("MiniDisplay.Run(): CAUGHT EXCEPTION in handler.DisplayLines() - {0}", exception2);
              if (exception2.Message.Contains("ThreadAbortException"))
              {
                this.stopRequested = true;
              }
            }
            Settings.Instance.LogDebug("MiniDisplay.Run(): MiniDisplay Sleeping...");
            Thread.Sleep(Settings.Instance.UpdateDelay);
            Settings.Instance.LogDebug("MiniDisplay.Run(): MiniDisplay Sleeping... DONE");         
          }
          else
          {
            Thread.Sleep(100);
          }
        }

        Settings.Instance.LogInfo("MiniDisplay.Run(): Stopping MiniDisplay displayhandler.");
        flag2 = true;
        this.handler.Stop();
      }
      catch (ThreadAbortException)
      {
        Log.Error("MiniDisplay.Run(): CAUGHT ThreadAbortException");
        if (!flag2)
        {
          this.handler.Stop();
          flag2 = true;
        }
      }
      catch (Exception exception3)
      {
        Log.Error("MiniDisplay.Run(): CAUGHT EXCEPTION: {0}", exception3);
      }
      Settings.Instance.LogInfo("MiniDisplay.Run(): Exiting MiniDisplay run loop.");
    }
Ejemplo n.º 2
0
 public void Run()
 {
   SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler(this.SystemEvents_PowerModeChanged);
   bool extensiveLogging = Settings.Instance.ExtensiveLogging;
   bool flag2 = false;
   if (extensiveLogging)
   {
     Log.Info("MiniDisplay.Run(): Entering MiniDisplay run loop.");
   }
   try
   {
     if (extensiveLogging)
     {
       Log.Info("MiniDisplay.Run(): Creating MiniDisplay displayhandler.");
     }
     this.handler = new DisplayHandler(this.display);
     if (extensiveLogging)
     {
       Log.Info("MiniDisplay.Run(): Starting MiniDisplay displayhandler.");
     }
     this.handler.Start();
     while (!this.stopRequested)
     {
       if (!Settings.Instance.Type.Equals("MCEDisplay"))
       {
         try
         {
           // It's not safe to call this method in other states than running, since
           // it calls the window manager. It might cause a dead lock in other states
           if (GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.RUNNING)
           {
             DoWork();
           }
         }
         catch (Exception exception)
         {
           Log.Debug("MiniDisplay.Run(): CAUGHT EXCEPTION in DoWork() - {0}", exception);
           if (exception.Message.Contains("ThreadAbortException"))
           {
             this.stopRequested = true;
           }
         }
         try
         {
           // It's not safe to call this method in other states than running, since
           // it calls the window manager. It might cause a dead lock in other states
           if (GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.RUNNING)
           {
             handler.DisplayLines();
           }
         }
         catch (Exception exception2)
         {
           Log.Debug("MiniDisplay.Run(): CAUGHT EXCEPTION in handler.DisplayLines() - {0}", exception2);
           if (exception2.Message.Contains("ThreadAbortException"))
           {
             this.stopRequested = true;
           }
         }
         if (extensiveLogging)
         {
           Log.Debug("MiniDisplay.Run(): MiniDisplay Sleeping...");
         }
         Thread.Sleep(Settings.Instance.ScrollDelay);
         if (extensiveLogging)
         {
           Log.Debug("MiniDisplay.Run(): MiniDisplay Sleeping... DONE");
         }
       }
       else
       {
         Thread.Sleep(100);
       }
     }
     if (extensiveLogging)
     {
       Log.Info("MiniDisplay.Run(): Stopping MiniDisplay displayhandler.");
     }
     flag2 = true;
     this.handler.Stop();
   }
   catch (ThreadAbortException)
   {
     Log.Error("MiniDisplay.Run(): CAUGHT ThreadAbortException");
     if (!flag2)
     {
       this.handler.Stop();
       flag2 = true;
     }
   }
   catch (Exception exception3)
   {
     Log.Error("MiniDisplay.Run(): CAUGHT EXCEPTION: {0}", exception3);
   }
   if (extensiveLogging)
   {
     Log.Info("MiniDisplay.Run(): Exiting MiniDisplay run loop.");
   }
 }
Ejemplo n.º 3
0
        //Render thread entry point
        public void Run()
        {
            SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler(this.SystemEvents_PowerModeChanged);
            bool flag2 = false;

            Settings.Instance.LogInfo("MiniDisplay.Run(): Entering MiniDisplay run loop.");
            try
            {
                Settings.Instance.LogInfo("MiniDisplay.Run(): Creating MiniDisplay displayhandler.");
                this.handler = new DisplayHandler(this.display);
                Settings.Instance.LogInfo("MiniDisplay.Run(): Starting MiniDisplay displayhandler.");
                this.handler.Start();
                while (!this.stopRequested)
                {
                    if (!Settings.Instance.Type.Equals("MCEDisplay"))
                    {
                        try
                        {
                            // It's not safe to call this method in other states than running, since
                            // it calls the window manager. It might cause a dead lock in other states
                            if (GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.RUNNING)
                            {
                                DoWork();
                            }
                        }
                        catch (Exception exception)
                        {
                            Log.Debug("MiniDisplay.Run(): CAUGHT EXCEPTION in DoWork() - {0}", exception);
                            if (exception.Message.Contains("ThreadAbortException"))
                            {
                                this.stopRequested = true;
                            }
                        }
                        try
                        {
                            // It's not safe to call this method in other states than running, since
                            // it calls the window manager. It might cause a dead lock in other states
                            if (GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.RUNNING)
                            {
                                //Is it time for us to scroll our texts?
                                if ((DateTime.Now - this.lastScroll).TotalMilliseconds >= Settings.Instance.ScrollDelay)
                                {
                                    this.lastScroll = DateTime.Now; //Mark the time
                                    //Take care of scrolling our texts
                                    handler.DisplayLines();
                                }

                                //Do update regardless of whether or not we scrolled our texts
                                handler.Update();
                            }
                        }
                        catch (Exception exception2)
                        {
                            Log.Debug("MiniDisplay.Run(): CAUGHT EXCEPTION in handler.DisplayLines() - {0}", exception2);
                            if (exception2.Message.Contains("ThreadAbortException"))
                            {
                                this.stopRequested = true;
                            }
                        }
                        Settings.Instance.LogDebug("MiniDisplay.Run(): MiniDisplay Sleeping...");
                        Thread.Sleep(Settings.Instance.UpdateDelay);
                        Settings.Instance.LogDebug("MiniDisplay.Run(): MiniDisplay Sleeping... DONE");
                    }
                    else
                    {
                        Thread.Sleep(100);
                    }
                }

                Settings.Instance.LogInfo("MiniDisplay.Run(): Stopping MiniDisplay displayhandler.");
                flag2 = true;
                this.handler.Stop();
            }
            catch (ThreadAbortException)
            {
                Log.Error("MiniDisplay.Run(): CAUGHT ThreadAbortException");
                if (!flag2)
                {
                    this.handler.Stop();
                    flag2 = true;
                }
            }
            catch (Exception exception3)
            {
                Log.Error("MiniDisplay.Run(): CAUGHT EXCEPTION: {0}", exception3);
            }
            Settings.Instance.LogInfo("MiniDisplay.Run(): Exiting MiniDisplay run loop.");
        }
Ejemplo n.º 4
0
        public void Run()
        {
            SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler(this.SystemEvents_PowerModeChanged);
            bool extensiveLogging = Settings.Instance.ExtensiveLogging;
            bool flag2            = false;

            if (extensiveLogging)
            {
                Log.Info("MiniDisplay.Run(): Entering MiniDisplay run loop.");
            }
            try
            {
                if (extensiveLogging)
                {
                    Log.Info("MiniDisplay.Run(): Creating MiniDisplay displayhandler.");
                }
                this.handler = new DisplayHandler(this.display);
                if (extensiveLogging)
                {
                    Log.Info("MiniDisplay.Run(): Starting MiniDisplay displayhandler.");
                }
                this.handler.Start();
                while (!this.stopRequested)
                {
                    if (!Settings.Instance.Type.Equals("MCEDisplay"))
                    {
                        try
                        {
                            // It's not safe to call this method in other states than running, since
                            // it calls the window manager. It might cause a dead lock in other states
                            if (GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.RUNNING)
                            {
                                DoWork();
                            }
                        }
                        catch (Exception exception)
                        {
                            Log.Debug("MiniDisplay.Run(): CAUGHT EXCEPTION in DoWork() - {0}", exception);
                            if (exception.Message.Contains("ThreadAbortException"))
                            {
                                this.stopRequested = true;
                            }
                        }
                        try
                        {
                            // It's not safe to call this method in other states than running, since
                            // it calls the window manager. It might cause a dead lock in other states
                            if (GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.RUNNING)
                            {
                                handler.DisplayLines();
                            }
                        }
                        catch (Exception exception2)
                        {
                            Log.Debug("MiniDisplay.Run(): CAUGHT EXCEPTION in handler.DisplayLines() - {0}", exception2);
                            if (exception2.Message.Contains("ThreadAbortException"))
                            {
                                this.stopRequested = true;
                            }
                        }
                        if (extensiveLogging)
                        {
                            Log.Debug("MiniDisplay.Run(): MiniDisplay Sleeping...");
                        }
                        Thread.Sleep(Settings.Instance.ScrollDelay);
                        if (extensiveLogging)
                        {
                            Log.Debug("MiniDisplay.Run(): MiniDisplay Sleeping... DONE");
                        }
                    }
                    else
                    {
                        Thread.Sleep(100);
                    }
                }
                if (extensiveLogging)
                {
                    Log.Info("MiniDisplay.Run(): Stopping MiniDisplay displayhandler.");
                }
                flag2 = true;
                this.handler.Stop();
            }
            catch (ThreadAbortException)
            {
                Log.Error("MiniDisplay.Run(): CAUGHT ThreadAbortException");
                if (!flag2)
                {
                    this.handler.Stop();
                    flag2 = true;
                }
            }
            catch (Exception exception3)
            {
                Log.Error("MiniDisplay.Run(): CAUGHT EXCEPTION: {0}", exception3);
            }
            if (extensiveLogging)
            {
                Log.Info("MiniDisplay.Run(): Exiting MiniDisplay run loop.");
            }
        }