Пример #1
0
        public void Start()
        {
            ShouldStart = true;

            _threadBlocker = new ThreadBlocker();
            _threadBlocker.BlockUntilCompleted(() => { _finished += delegate { _threadBlocker.Completed(); }; });
        }
Пример #2
0
        public void Start()
        {
            ShouldStart = true;

              _threadBlocker = new ThreadBlocker();
              _threadBlocker.BlockUntilCompleted(() => { _finished += delegate { _threadBlocker.Completed(); }; });
        }
Пример #3
0
        public void ShowModalDialog(object dialog, DialogType type, InteractionState?interactionState = null)
        {
            var blocker = new ThreadBlocker();

            blocker.BlockUntilCompleted(() =>
            {
                ShowDialog(dialog, type, interactionState);
                ((IClosable)dialog).Closed += delegate { blocker.Completed(); };
            });
        }
Пример #4
0
        public void ChangeScreen(object screen, bool blockUntilClosed = false, bool shouldClosePrevious = true)
        {
            if (Screen != null && shouldClosePrevious)
              {
            Screen.Close();
              }

              Screen = screen;

              if (blockUntilClosed == false)
            return;

              var blocker = new ThreadBlocker();
              blocker.BlockUntilCompleted(() => { ((IClosable) screen).Closed += delegate { blocker.Completed(); }; });
        }
Пример #5
0
        public void ChangeScreen(object screen, bool blockUntilClosed = false, bool shouldClosePrevious = true)
        {
            if (Screen != null && shouldClosePrevious)
            {
                Screen.Close();
            }

            Screen = screen;

            if (blockUntilClosed == false)
            {
                return;
            }

            var blocker = new ThreadBlocker();

            blocker.BlockUntilCompleted(() => { ((IClosable)screen).Closed += delegate { blocker.Completed(); }; });
        }
Пример #6
0
        public CardInfo PickCard(List <CardInfo> booster, int round)
        {
            Round = round;

            BoosterRow1 = CreateCards(booster.Take(5)).ToList();
            BoosterRow2 = CreateCards(booster.Skip(5).Take(5)).ToList();
            BoosterRow3 = CreateCards(booster.Skip(10).Take(5)).ToList();
            Direction   = round == 2 ? "Up" : "Down";

            CardsLeft = (3 - round) * 15 + booster.Count;

            _blocker = new ThreadBlocker();
            _blocker.BlockUntilCompleted();

            if (PlayerLeftDraft)
            {
                return(null);
            }

            return(booster.First(x => x.Name.Equals(PickedCard.Name, StringComparison.InvariantCultureIgnoreCase)));
        }
Пример #7
0
        private bool RunGame(Game game)
        {
            Game = game;

            var playScreen = Ui.Dialogs.PlayScreen.Create();

            Ui.Shell.ChangeScreen(playScreen);

            var blocker = new ThreadBlocker();

            AggregateException exception = null;

            blocker.BlockUntilCompleted(() => Task.Factory
                                        .StartNew(() => Game.Start(looser: Looser), TaskCreationOptions.LongRunning)
                                        .ContinueWith(t => { exception = t.Exception; }, TaskContinuationOptions.OnlyOnFaulted)
                                        .ContinueWith(t => blocker.Completed()));

            if (exception != null)
            {
                throw new AggregateException(exception.InnerExceptions);
            }

            return(ProcessGameResults());
        }
Пример #8
0
        public CardInfo PickCard(List<CardInfo> booster, int round)
        {
            Round = round;

              BoosterRow1 = CreateCards(booster.Take(5)).ToList();
              BoosterRow2 = CreateCards(booster.Skip(5).Take(5)).ToList();
              BoosterRow3 = CreateCards(booster.Skip(10).Take(5)).ToList();
              Direction = round == 2 ? "Up" : "Down";

              CardsLeft = (3 - round)*15 + booster.Count;

              _blocker = new ThreadBlocker();
              _blocker.BlockUntilCompleted();

              if (PlayerLeftDraft)
            return null;

              return booster.First(x => x.Name.Equals(PickedCard.Name, StringComparison.InvariantCultureIgnoreCase));
        }
Пример #9
0
        public void ShowModalDialog(object dialog, DialogType type, InteractionState? interactionState = null)
        {
            var blocker = new ThreadBlocker();

              blocker.BlockUntilCompleted(() =>
            {
              ShowDialog(dialog, type, interactionState);
              ((IClosable) dialog).Closed += delegate { blocker.Completed(); };
            });
        }