/// <summary> /// Asynchronously read from the queue and put the content into /// the provided StringBuilder. /// <param name="sb">Hold the read content.</param> /// <param name="ev">Synchronisation event used by the calling thread.</param> /// </summary> public void AsyncRecv(StringBuilder sb, ManualResetEvent ev) { MessageState ms = new MessageState(this._sock, ev); ms.Data = sb; this._sock.BeginReceive(ms.Buffer, 0, 1024, 0, new AsyncCallback(this.ReceiveCallback), ms); }
/// <summary> /// Asynchronously send a message as an XML string. /// </summary> /// <param name="xml">Message representation as an XML string.</param> /// <param name="ev">Synchronisation event used by the calling thread.</param> public void AsyncSend(string xml, ManualResetEvent ev) { byte[] buffer = System.Text.Encoding.ASCII.GetBytes(xml); MessageState ms = new MessageState(this._sock, ev); this._sock.BeginSend(buffer, buffer.Length, 0, SocketFlags.None, new AsyncCallback(this.SendCallback), ms); }