Torna al Thread
public string Read()
{
string OutputValue = "";
int c = 0;
while (true)
{
try
{
if (this._networkStream.DataAvailable)
{
while (this._networkStream.DataAvailable)
{
this._receivedBuffer = new byte[0x400];
c = this._networkStream.Read(this._receivedBuffer, 0, this._receivedBuffer.Length);
OutputValue = OutputValue + Encoding.ASCII.GetString(this._receivedBuffer, 0, c);
}
return OutputValue;
}
Thread.Sleep(500);
}
catch (Exception ex)
{
return ex.Message;
}
}
}
public void Send(string command)
{
string c = command.Replace("\n", br);
byte[] msg = Encoding.ASCII.GetBytes(c+br);
if (_networkStream.CanWrite)
{
this._networkStream.Write(msg, 0, msg.Length);
this._networkStream.Flush();
}
}