-
Notifications
You must be signed in to change notification settings - Fork 0
/
Writer.cs
34 lines (31 loc) · 1.16 KB
/
Writer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestApp
{
class Writer : FileUser
{
private int _blockCount = 0; // Это поле используется для визуализации в консоли (для красоты).
internal Writer(string filePath, NumberedQueue buffer) : base(buffer)
{
fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None);
}
internal void WriteResultToFile()
{
while(true)
{
DataBlock block = buffer.ReadBlock();
if (block.Data == null)
{
Console.WriteLine("\r" + "Processing...".PadRight(++_blockCount % 20, '.').PadRight(40)); // Визуализация в консоли.
return;
}
fs.Write(block.Data, 0, block.Data.Length);
Console.Write("\r" + "Processing".PadRight(++_blockCount % 20, '.').PadRight(40)); // Визуализация в консоли.
}
}
}
}