我需要检查我的客户端是否有缓冲区,以便我不必等待写入。
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' 是否为空?
注:使用Mono的C#