Ejemplo n.º 1
0
        void _equalsButton_Click(object sender, RoutedEventArgs e)
        {
            double operand1 = double.Parse(_operand1.Text);
            double operand2 = double.Parse(_operand2.Text);
            string opcode   = ((TextBlock)_op.SelectedValue).Text;

            // Start the call to the web service asynchronously, calling CalcComplete
            // when each calculation is complete and passing the calc opcode via
            // IAsyncResult.AsyncState so we can know which proxy End method to call
            switch (opcode)
            {
            case "+":
                client.BeginAdd(operand1, operand2, CalcComplete, opcode);
                break;

            case "-":
                client.BeginSubtract(operand1, operand2, CalcComplete, opcode);
                break;

            case "*":
                client.BeginMultiply(operand1, operand2, CalcComplete, opcode);
                break;

            case "/":
                client.BeginDivide(operand1, operand2, CalcComplete, opcode);
                break;
            }

            // Let the user know
            _numberTextBlock.Text = "(getting result)";
        }