Example #1
0
 private void ReceiveMessages()
 {
     try
     {
         // Constantly receive messages from client and display in text box
         while (true)
         {
             // When a non empty message was received display it
             string msg = client.Receive();
             if (msg != string.Empty)
             {
                 AppendTextBox(">> " + msg + Environment.NewLine);
             }
         }
     }
     catch (Exception ex)
     {
         // Show message box with error details if connecting fails
         MessageBoxButtons buttons = MessageBoxButtons.OK;
         MessageBox.Show(ex.Message, "Error", buttons);
         CloseForm();
     }
 }