正如标题中提到的,我基本上正在开发一个程序(服务器/客户端) 服务器在表行中插入一些数据,客户端正在读取数据。
while (true)
{
string Command = ReadData();
//Read row
if (Command != string.Empty)
{
switch(Command)
{
case "Connection":
Console.writeLine("Connected !");
break;
}
}
else
{
console.writeLine("No data were found ! ");
}
}
Readata();
如果在一行中找到,函数仅返回一个字符串。
该行中的默认数据为 Null
- 在服务器插入一些信息(例如命令)之前,该行中没有存储数据。
客户端将始终读取该行,并且每次它发现除 null 之外的内容时,它都会执行一些代码。
执行时不会破坏程序吗?
希望我的问题很清楚,祝你有美好的一天!
最佳答案
如果客户端正确处理该行不存在的情况,则不会破坏程序。
例如(伪代码)
loop {
checkForRow();
if (row.exists) {
readRowData();
clearRowData();
}
}
关于C# 无限行读取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39400415/