Ejemplo n.º 1
0
 private void toggleWprgmRun_ToggleClick(object sender,
                                         System.EventArgs e,
                                         Mockingbird.HP.Control_Library.TogglePosition position)
 {
     // Changes to this toggle are actually delayed until the end of the current execution.
     // If the execution thread is idle, we are going to be able to grab the lock and
     // proceed immediately.  If it is busy, we won't be able to grab the lock, and we will
     // return without doing anything.  That's not a problem because the execution thread
     // will update the menus as soon as the current computation finishes.
     if (Monitor.TryEnter(executionThread.IsBusy))
     {
         try
         {
             // One of the things we want to do is change the display mode, and that can
             // only be done by the execution thread.  So force it to go through its loop
             // once by sending a no-op keystroke.  We know that the execution thread is
             // idle, so this won't have nasty effects like interrupting the current
             // computation.
             executionThread.Enqueue(Keystroke.Noop);
         }
         finally
         {
             Monitor.Exit(executionThread.IsBusy);
         }
     }
 }
Ejemplo n.º 2
0
        protected void toggleWprgmRun_ToggleMoved(object sender,
                                                  Mockingbird.HP.Control_Library.TogglePosition position)
        {
            // Changes to this toggle are actually delayed until the end of the current execution.
            // If the execution thread is idle, we are going to be able to grab the lock and
            // proceed immediately.  If it is busy, we won't be able to grab the lock, and we will
            // return without doing anything.  That's not a problem because the execution thread
            // will update the menus as soon as the current computation finishes.

            // Ask the execution thread to refresh its state based on the new state of the
            // UI.  This will cause the display mode and the menus to reflect the current
            // position of the toggle.
            //TODO: This comment is incorrect.
            switch (position)
            {
            case TogglePosition.Left:
                executionThread.Enqueue
                    (new ExecutionModeMessage(EngineModes.Execution.WriteProgram));
                break;

            case TogglePosition.Right:
                executionThread.Enqueue
                    (new ExecutionModeMessage(EngineModes.Execution.Run));
                break;

            default:
                Trace.Assert(false);
                break;
            }
        }
Ejemplo n.º 3
0
        private void toggleOffOn_ToggleClick(object sender,
                                             System.EventArgs e,
                                             Mockingbird.HP.Control_Library.TogglePosition position)
        {
            switch (toggleOffOn.Position)
            {
            case TogglePosition.Left:
                PowerOff();
                break;

            case TogglePosition.Right:
                // ON.  First, we cancel any key typed when the power was off.  Then we enqueue
                // a dummy keystroke to cause the execution thread to set the display mode.
                // Finally we release the execution thread.
                executionThread.Clear();
                executionThread.Enqueue(Keystroke.Noop);
                executionThread.PowerOn.Set();
                break;
            }
        }