【发布时间】:2015-12-27 13:11:53
【问题描述】:
我需要检查我的客户端是否在缓冲区中有东西,所以我没有等着写。
private async void ThreadMethod_ListenClient()
{
while (true) {
if (ClientQueue.Count == 0)
continue;
Client client = (Client)ClientQueue.Dequeue ();
if (client.Reader != null) {
string Say = await client.Reader.ReadLineAsync();
if (Say != null) {
if (Say.Length != 0) {
Console.WriteLine (Say);
}
}
}
ClientQueue.Enqueue (client);
}
}
client.Reader : 来自 TcpClient 的 StreamReader
client.Socket : TcpClient
如何检查'client.Reader'是否为空?
obs。带有单声道的 C#
【问题讨论】:
-
if (Say != null)回答您自己的问题!
标签: c# sockets streamreader