Ejemplo n.º 1
0
 private void SaveProcessedChunks()
 {
     try
     {
         using var file = fileWriter.OpenFile(fileInfo, jobContext.Operation == Operation.Decompress);
         foreach (var processedBatchItem in processedJobQueue.GetConsumingEnumerable())
         {
             if (!cancellationToken.IsCancellationRequested)
             {
                 jobContext.ProcessedId = processedBatchItem.JobBatchItemId;
                 file.Write(processedBatchItem.Processed.Memory.Span);
                 processedBatchItem.Processed.ReturnBuffer();
             }
             else
             {
                 break;
             }
         }
     }
     catch (Exception e)
     {
         jobContext.Failure(e, e.Message);
         cancellationTokenSource.Cancel();
     }
     finally
     {
         countdown.Signal();
     }
 }