public byte[] GetSendBytes() { List <byte> send = null; lock (SendBuffer) { send = new List <byte>(); int length = SendBuffer.Count; byte[] lengthB = BitConverter.GetBytes(length); send.AddRange(lengthB); byte[] body = SendBuffer.ToArray(); send.AddRange(body); // SendBuffer.Clear(); } return(send.ToArray()); }