private void BtnStart_Click(object sender, RoutedEventArgs e)
        {
            var port = TbPort.Text;

            _running = true;
            var ipaddress = TbIpAddress.Text;

            Task.Run(() => { SocketServerEx.StartListening(port, ipaddress); });
            Lstatus.Content    = "Listening";
            BtnStart.IsEnabled = false;
            new Task(GetDataAndUpdateConsoleOutputBox).Start();
        }
Ejemplo n.º 2
0
 private void btnStartServer_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         string      strPort      = tbPort.Text;
         ListBoxItem selectedItem = (ListBoxItem)cbIPAddresses.SelectedItem;
         string      strIPAddress = (string)selectedItem.Content;
         if (!areTasksStarted)
         {
             Task.Run(() => SocketServerEx.StartListening(strPort, strIPAddress));
             new Task(GetDataAndUpdateConsolOutputBox).Start();
             Task.Run(() => UpdateClientsListBox());
             areTasksStarted = true;
         }
         lbStatus.Content         = "Listening";
         btnStartServer.IsEnabled = false;
         btnSend.IsEnabled        = true;
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
 }
Ejemplo n.º 3
0
        private void BtnStartServer_Click(object sender, RoutedEventArgs e)
        {
            var strPort = tbPort.Text;
            //var strIp = tbIpAddress.Text;
            ListBoxItem selectedItem = (ListBoxItem)cbIPAddress.SelectedItem;
            string      strIpAddress = (string)selectedItem.Content;

            if (!areTasksStarted)
            {
                Task.Run(() => SocketServerEx.StartListening(strPort, strIpAddress));
                new Task(GetDataAndUpdateConsoleOutputBox).Start();
                Task.Run(() => UpdatedClientListBox());
                areTasksStarted = true;
            }
            lblStatus.Content        = "listening";
            btnStartServer.IsEnabled = false;
            btnSend.IsEnabled        = true;

            //Task.Run(() => SocketServerEx.StartListening(strPort, strIp));
            //lblStatus.Content = "listening";
            //btnStartServer.IsEnabled = false;
            //var t = new Task(GetDataAndUpdateConsoleOutputBox);
            //t.Start();
        }