public void BinaryListenTask( ) { try { byte currentSequence = 0; while (IsRunning) { if (UnderlyingStream.ReadByte( ) == DatagramHeaderInt) { byte sequence = ( byte )UnderlyingStream.ReadByte( ); if (sequence == currentSequence) { currentSequence++; } else { //Todo:??? } BinaryDatagramType type = ( BinaryDatagramType )( byte )UnderlyingStream.ReadByte( ); //todo:if not throw byte crc = ( byte )UnderlyingStream.ReadByte( ); byte length = ( byte )UnderlyingStream.ReadByte( ); byte [] data = new byte[length]; UnderlyingStream.Read(data, 0, length); if (data.CaluCrc8( ) == crc) { if (Datagram.Parse(type, data) is ReceiveDatagram datagram) { ReceiveQueue.Enqueue(datagram); } } else { //todo:Warning? } } } } catch (ThreadAbortException) { } }