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 by creating a phony calc result object // (which the GUI knows how to bind to) and setting the words CalcResult progress = new CalcResult(); progress.Words = "(getting results)"; this.DataContext = progress; }
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 = ""; _wordsTextBlock.Text = "(getting results)"; }