private void Read(string filePath, IWriteQueue <ByteBlock> queue, Func <BinaryReader, long, ByteBlock> reading) { try { var count = 0; using (BinaryReader binaryReader = new BinaryReader(File.OpenRead(filePath))) { while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length) { if (_zipController.IsCancelled) { throw new AbortedOperationException($"Read file {filePath}"); } var dataBlock = reading(binaryReader, count); queue.Enqueue(dataBlock); count++; } } } catch (Exception ex) { LoggerProvider.Logger().Error($"Error. Read the file: {ex.Message}"); } }
public void Enqueue(object message) { // Since we eagerly dispose ourselves after failing to connect // to the server, we don't check for disposal here but rather // perform a no-op by using a NullQueue. _writeQueue.Enqueue(message); }
void Send(object message) { _client.Enqueue(message); }