public void Start() { ShouldStart = true; _threadBlocker = new ThreadBlocker(); _threadBlocker.BlockUntilCompleted(() => { _finished += delegate { _threadBlocker.Completed(); }; }); }
public void Start() { ShouldStart = true; _threadBlocker = new ThreadBlocker(); _threadBlocker.BlockUntilCompleted(() => { _finished += delegate { _threadBlocker.Completed(); }; }); }
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(); }; }); }
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(); }; }); }
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(); }; }); }
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))); }
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()); }
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)); }
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(); }; }); }