Example #1
0
        public void Start()
        {
            try
            {
                StartRoundEventArgs args = new StartRoundEventArgs();
                args.TaskPool          = TaskPool;
                args.Token             = Token;
                args.CancelTokenSource = CancelTokenSource;
                args.WinLength         = WinLength;

                StartGameHandler?.Invoke(this, args);

                Task.WaitAll(TaskPool.ToArray(), Token);
            }
            catch (OperationCanceledException ex)
            {
                //throw new Exception("Stop game");
            }
            catch (Exception ex)
            {
                throw new Exception("Start game exception", ex.InnerException);
            }
            finally
            {
                if (FinishGameHandler != null)
                {
                    FinishGameHandler.Invoke(this, new System.EventArgs());
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("{0} : {1} ---- {2} : {3}", Team1.Name, Team1.Count, Team2.Name, Team2.Count);
                    Console.WriteLine("End GAME!!!");
                }
            }
        }
Example #2
0
 // Start game
 private void buttonStartGame_Click(object sender, RoutedEventArgs e)
 {
     OnStartGame?.Invoke();
 }