Cru Dy Cru Dy - 2 months ago 16
MySQL Question

c# infinite rows reading

as noticed in title , i'am basically developping a program (Server/client)
where the server insert some data in a table row , and the client is reading the data .

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 ! ");
}
}


the
Readata();
function it only return a string that found in a row .

The default Data in that Row : is
Null
there is no stored data in that row until the server insert some information like a Command on it .

the Client while always read that row and foreach time he find something except null he will execute some code .

Won't that break the program while executed ?

hope that my question is clear and have a nice day !

Answer

It won't break the program if the client appropriately handles the case where the row doesn't exist.

For example (pseudo code)

loop {
   checkForRow();
   if (row.exists) {
      readRowData();
      clearRowData();
   }
}
Comments