Exemple #1
0
 public void FileRead()
 {
     _readFileInfo = GenerateFile();
     using (var reader = new ChunkedFileReader(_readFileInfo, _maxChunkSize, new System.Threading.CancellationToken()))
     {
         reader.ChunkRead += (chunk, isLastChunk) => _proccessedReadBytes += chunk.Bytes.Length;
         reader.OnError   += error => Assert.Fail(error.GetException().StackTrace);
         reader.ReadAllBytes();
     }
     Assert.AreEqual(_proccessedReadBytes, _readFileInfo.Length);
 }
Exemple #2
0
 public int Run()
 {
     for (int i = 0; i < ThreadsNumber;)
     {
         var thread = new Thread(_chunkedHandler.Start);
         thread.Name = $"Chunked handler: {++i}";
         thread.Start();
     }
     _reader.ReadAllBytes();
     _allBytesWritten.WaitOne();
     return(Convert.ToInt32(_token.IsCancellationRequested));
 }