コード例 #1
0
ファイル: Form1.cs プロジェクト: seonhui613/csharp
 public void Chat_Process()
 {
     while (true)
     {
         try
         {
             string lstMessage = strReader.ReadLine();
             if (lstMessage != null && lstMessage != "")
             {
                 form1.SetText(lstMessage + "\r\n");
             }
         }
         catch (System.Exception)
         {
             break;
         }
     }
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: elinmk627/csharp
 public void Chat_Process()
 {
     while (true)
     {
         try  {
             //문자열을 받음
             string lstMessage = strReader.ReadLine();
             if (lstMessage != null && lstMessage != "")
             {
                 form1.SetText(lstMessage + "\r\n");         //SetText의 델리게이트를 이용하여 서버에서 넘어오는 메시지를 쓴다.
                 //this.txt_Chat.AppendText(lstMessage + "\r\n");        //직접쓰면 에러발생
             }
         }
         catch (System.Exception) {
             break;
         }
     }
 }
コード例 #3
0
        // 서버와 연결된 상태일 때 반복적으로 처리될 Chat_Process 메서드를 선언
        public void Chat_Process()
        {
            while (true)
            {
                try
                {
                    // strReader의 ReadLine메서드를 이용해 stream 상의 데이터를 읽은 후 string 자료형 변수 lstMessage에 할당
                    string lstMessage = strReader.ReadLine();

                    // 만약 lstMessage에 할당된 값이 null이 아니고 빈 문자열도 아니라면
                    if (lstMessage != null && lstMessage != "")
                    {
                        // lstMessage에 할당된 값과 두 번의 줄바꿈을 파라메터로 하여 객체 form1의 SetText 메서드를 호출
                        form1.SetText(lstMessage + "\n\n");
                    }
                }
                catch (Exception)
                {
                    // 예외가 발생하면 Chat_Process 메서드를 중단
                    break;
                }
            }
        }