Beispiel #1
0
 private async void ConnectButton_OnClick(object sender, RoutedEventArgs e)
 {
     try
     {
         if (_client.IsConnected)
         {
             throw new InvalidOperationException("Cannot connect while already connected");
         }
         IsEnabled = false;
         await _client.Connect();
     }
     catch (Exception ex)
     {
         MessageBox.Show(this.GetParentWindowRecurs(), ex.Message);
     }
     finally
     {
         IsEnabled = true;
     }
 }
Beispiel #2
0
        private static async Task Main()
        {
            try
            {
                const string ipAddress = "40.76.93.179";
                //const string ipAddress = "127.0.0.1";
                const int port = 500;

                var client = new TheClient(ipAddress, port);
                await client.Connect();

                Console.WriteLine("done....");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                Console.ReadKey();
            }
        }