Example #1
0
        private static void HandleNewInput(Guid instanceId, String message)
        {
            Console.WriteLine(message);
            if (message.StartsWith("Congratulations"))
            {
                waitEvent.Set();
                return;
            }

            String input = Console.ReadLine();

            if (!String.IsNullOrEmpty(input))
            {
                Int32 guess = 0;
                if (Int32.TryParse(input, out guess))
                {
                    ggService.OnGuessReceived(
                        new GuessReceivedEventArgs(instanceId, guess));
                }
            }
            else
            {
                waitEvent.Set();
            }
        }
Example #2
0
 private void btnGuess_Click(object sender, EventArgs e)
 {
     //pass the guess to the running workflow
     try
     {
         Int32 nextGuess = Int32.Parse(txtNextNumber.Text);
         //raise the GuessReceived event in the game service
         _gameService.OnGuessReceived(
             new GuessReceivedEventArgs(_instanceId, nextGuess));
     }
     catch (FormatException)
     {
         MessageBox.Show("Could not parse the number");
     }
     catch (OverflowException)
     {
         MessageBox.Show("The number exceeded the allowed limits");
     }
     catch (EventDeliveryFailedException)
     {
         MessageBox.Show(
             "Your guess was not delivered.\n\rStart a new game.",
             "Game Ended", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
     }
 }