public static PacketParser GetParser(int bufferBlockSize) { if (!ParserCache.TryGetValue(bufferBlockSize, out ConcurrentQueue <PacketParser> queue)) { queue = new ConcurrentQueue <PacketParser>(); ParserCache[bufferBlockSize] = queue; } if (!queue.TryDequeue(out PacketParser packet)) { packet = new PacketParser(bufferBlockSize); } return(packet); }