Exemplo n.º 1
0
        public async Task Refresh()
        {
            await RefreshImagesList();
            await RefreshContainerList();

            StageChanged?.Invoke();
        }
Exemplo n.º 2
0
        private void stageChanged(Stage oldValue, Stage newValue)
        {
            var args = new StageChangedEventArgs {
                OldStage = oldValue, NewStage = newValue
            };

            StageChanged?.Invoke(this, args);
        }
Exemplo n.º 3
0
 private IAction InitialDispatcher(IAction action)
 {
     lock (syncLock) {
         var cloned = ObjectExtensions.Copy(state);
         state = reducer(cloned, action);
     }
     StageChanged?.Invoke();
     return(action);
 }
Exemplo n.º 4
0
        private void ChangeStage(Stage stage)
        {
            // Interrupt and fast-forward the current stage process, if it had no time to iterate completely.
            FastForward();

            Stage = stage;
            SetCurrentStageProcess();
            process.Start();

            StageChanged?.Invoke(this, new ActivationStateChangedEventArgs(stage));
        }
Exemplo n.º 5
0
    private void IncreaseStage()
    {
        _stage++;
        int currentMaxStage = saver.MaxStage;

        if (_stage > currentMaxStage)
        {
            saver.SaveMaxStage(_stage);
        }
        saver.SaveCurrentScore(_score);
        saver.SaveCurrentStage(_stage);
        StageChanged?.Invoke(_stage);
    }
Exemplo n.º 6
0
        private void ChangeStage(Stage stage)
        {
            // Interrupt and fast-forward the current stage process, if it had no time to iterate completely.
            FastForward();

            Stage = stage;
            Owner.InvokeProcessStart();
            update = Owner.InvokeProcessUpdate();

            if (StageChanged != null)
            {
                StageChanged.Invoke(this, new ActivationStateChangedEventArgs(stage));
            }
        }
Exemplo n.º 7
0
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
        public async Task Disconnect()
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
        {
            connected = false;

            lock (monitor)
            {
                foreach (DockerLogReader logReader in logReaders.Values)
                {
                    logReader.Stop();
                }
                logReaders.Clear();
                images.Clear();
                containers.Clear();
            }

            StageChanged?.Invoke();
        }
Exemplo n.º 8
0
        private void DoWork()
        {
            /* Check frozen. */
            if (FreezableClock.IsFrozen && !_pausedEvent.WaitOne())
            {
                return;
            }

            var now = ProgramTime;

            /* Do sleep waiting while greater than 2 x sleep period */
            var sleepWaitPeriod = SleepWaitPeriod;

            if (sleepWaitPeriod.Ticks > 0)
            {
                while (!_stageSkipped.Value && FreezableClock.Unit.ConvertTo((long)(_nextUpdateTime - now), TimeUnit.Tick) > sleepWaitPeriod.Ticks * 2)
                {
                    Thread.Sleep(sleepWaitPeriod);
                    now = ProgramTime;
                }
            }

            /* Do busy waiting while less than 2 x sleep period */
            while (now < _nextUpdateTime && !_stageSkipped.Value)
            {
                if (FreezableClock.IsFrozen)
                {
                    return;                          /* Exit busy waiting while paused */
                }
                now = ProgramTime;
            }

            /* Actual processing procedures */
            do
            {
                /* Reset skip state */
                _stageSkipped.Reset();

                /* Get next stage, exit on null (END REACHED) */
                Stage stage = null;
                try
                {
                    for (;;) /* Loop only for skip */
                    {
                        stage = _stageProvider.Next();
                        now   = ProgramTime;
                        var eventArgs = new StageChangedEventArgs(now, stage);
                        StageChanged?.Invoke(this, eventArgs);
                        if (stage == null)
                        {
                            eventArgs.Action = StageAction.Terminate;
                        }
                        switch (eventArgs.Action)
                        {
                        case StageAction.Terminate:     /* Terminate entire program */
                            goto StopProgram;

                        case StageAction.Skip:     /* Skip current stage directly */
                            continue;

                        case StageAction.Pause:     /* Pause at the start of the stage */
                            Pause();
                            goto BreakOuterLoop;

                        default:     /* Accepted */
                            goto BreakOuterLoop;
                        }

BreakOuterLoop:
                        break;
                    }
                }
                catch (ThreadAbortException) { throw; } /* Aborted by stopping underlying runner */
                catch (Exception e) /* Process unhandled exception */
                {
                    var eventArgs = new ExceptionEventArgs(e);
                    UnhandledException?.Invoke(this, eventArgs);
                    if (!eventArgs.Handled)
                    {
                        throw new Exception("Unhandled exception", e);
                    }
                }

                /* Update time */
                if (stage != null)
                {
                    _nextUpdateTime = now + stage.Duration;
                }
                continue;

                /* Stop */
StopProgram:
                Stop();
                return;
            } while (now >= _nextUpdateTime || _stageSkipped.Value); /* Check if need to move next */
        }
Exemplo n.º 9
0
 private void ChangeStage(bool playing)
 {
     PlayingStage = playing;
     StageChanged?.Invoke();
 }
Exemplo n.º 10
0
 private void ChangeStage(ModelStage stage)
 {
     Stage = stage;
     StageChanged?.Invoke(Stage);
 }
Exemplo n.º 11
0
 private void ChangeStage(GameStage stage)
 {
     this.stage = stage;
     StageChanged?.Invoke(stage);
 }
Exemplo n.º 12
0
 private void HandleStageFinished(object sender, StageCallbackEventArgs e)
 {
     StageChanged?.Invoke();
 }
Exemplo n.º 13
0
 public void ChangeStage(GameStage stage)
 {
     Stage = stage;
     StageChanged?.Invoke(stage);
 }
Exemplo n.º 14
0
        //---------------------------------------------------------------------------

        private void OnStageChanged()
        {
            StageChanged?.Invoke();
        }