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(); } }
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5