private void writeBlocksThread() { if (_lockedThreadsException != null) { return; } while (true) { var block = new BlockWithPosition(); while (_decompressedBlocks.TryPop(out block) == false && _lockedIsFileDecompressed == false) { } if (block == null) { break; } lock (_writeLocker) { try { _blockWriter.WriteBlock(_outputFile, block.Position, block.Block); } catch (Exception ex) { _lockedThreadsException = ex; break; } } } }
private void writeBlockThread() { if (_lockedThreadsException != null) { return; } while (true) { BlockWithPosition block = null; while (_compressedBlocks.TryPop(out block) == false && _lockedIsFileCompressed == false) { } if (block == null) { break; } var blockWithPosLen = new byte[8 + 4 + block.Block.Length]; BitConverter.GetBytes(block.Position).CopyTo(blockWithPosLen, 0); BitConverter.GetBytes(block.Block.Length).CopyTo(blockWithPosLen, 8); block.Block.CopyTo(blockWithPosLen, 12); lock (_writeLocker) { try { _blockWriter.WriteBlock(_outputFile, _outputFile.Position, blockWithPosLen); } catch (Exception ex) { _lockedThreadsException = ex; break; } } } }