Exemple #1
0
        private void btMnoz_Click(object sender, EventArgs e)
        {
            double.TryParse(textReal1.Text, out z1r);
            double.TryParse(textImag1.Text, out z1i);
            double.TryParse(textReal2.Text, out z2r);
            double.TryParse(textImag2.Text, out z2i);

            z1   = new ServiceReference.Zespolone();
            z1.R = z1r;
            z1.I = z1i;

            z2   = new ServiceReference.Zespolone();
            z2.R = z2r;
            z2.I = z2i;

            ServiceReference.Service1Client client = new ServiceReference.Service1Client();

            if (checkBox1.Checked)
            {
                // async
                try
                {
                    client.BeginZMnoz(z1, z2, ZMnozCallback, client);
                }
                catch (CommunicationException ex)
                {
                    MessageBox.Show(ex.Message, "Błąd komunikacji.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                try
                {
                    client.Open();
                    z = client.ZMnoz(z1, z2);
                    client.Close();
                    textResponse.Text = ZespolonaToString(z);
                }
                catch (CommunicationException ex)
                {
                    MessageBox.Show(ex.Message, "Błąd komunikacji.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    client.Abort();
                }
            }
        }