Exemplo n.º 1
0
        //----< start listener >-----------------------------------------
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            Peer p = new Peer(textBox1.Text, textBox2.Text, textBox6.Text);
            mPeer = p;
            mPeer.AddSelf();
              string localPort = textBox2.Text;
              string endpoint = "http://localhost:" + localPort + "/ICommunicator";

              try
              {
            recvr = new WCF_Peer_Comm.Receiver();
            recvr.CreateRecvChannel(endpoint);

            // create receive thread - calls BlockingQ.deQ()
            thrd = new Thread(new ThreadStart(this.ThreadProc));
            thrd.IsBackground = true;
            thrd.Start();
            button1.IsEnabled = true;
            button2.IsEnabled = false;
              }
              catch (Exception ex)
              {
            Window temp = new Window();
            StringBuilder msg = new StringBuilder(ex.Message);
            msg.Append("\nport = ");
            msg.Append(localPort.ToString());
            temp.Content = msg.ToString();
            temp.Height = 100;
            temp.Width = 500;
            temp.Show();
              }
        }