public void Read() { try { var filePartBuffer = new List <FilePart>(); using (var fs = new FileStream(_filePath, FileMode.Open)) { var index = 0; while (fs.Position < fs.Length) { filePartBuffer.Add(GetFilePart(fs, index)); index++; if (filePartBuffer.Count >= ProgramSettings.MaxFilePartBufferCount) { filePartBuffer = NotifyPartsReadAndWait(filePartBuffer); } } } if (filePartBuffer.Any()) { NotifyPartsReadAndWait(filePartBuffer); } NotifyCompleted?.Invoke(); } catch (Exception ex) { Console.WriteLine(ex.Message); throw; } }
protected void WriteStream(Stream stream) { while (true) { WriteParts(stream); if (!IsCompleted || _parts != null) { continue; } NotifyCompleted?.Invoke(); break; } }