因此,我一直在使用C#作爲Windows窗體應用程序中的聊天應用程序,並且在接收數據的代碼必須執行時,程序會凍結。C#聊天應用程序執行代碼時會凍結
任何人都可以幫助我,找出最新的錯誤。作爲一個控制檯應用程序,
UdpClient udpClient = new UdpClient(Convert.ToInt32(textPort.Text));
IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);
Byte[] receiveBytes = udpClient.Receive(ref RemoteIpEndPoint);
string returnData = Encoding.ASCII.GetString(receiveBytes);
textMsg.Text = returnData.ToString();
如果您使用的是調試器,您可以更具體地瞭解它在哪裏凍結? – FuzzyBunnySlippers
查找如何使用[BeginReceive](http://msdn.microsoft.com/en-us/library/system.net.sockets.udpclient.beginreceive(v = vs.110).aspx) – rene
at「Byte [ ] receiveBytes = udpClient.Receive(ref RemoteIpEndPoint);「 (它似乎是這樣) – user3002135