Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. try {
  2. int bytesRead = 0;
  3. var operationStart = DateTime.Now;
  4. var vt = sourceFile.ReadAsync(writeTask.Data);
  5. if (vt.IsCompletedSuccessfully) {
  6. bytesRead = vt.Result;
  7. }
  8. else {
  9. var t = vt.AsTask();
  10. if (!t.Wait(State.TransferTimeoutSeconds * 1000))
  11. throw new AggregateException(new TimeoutException("Reader timed out."));
  12. bytesRead = t.Result;
  13. }
  14. writeTask.Data = writeTask.Data.Slice(0, bytesRead);
  15. var operationDuration = (DateTime.Now - operationStart);
  16. volumeHealthReport.ReadStatistics.UpdateBandwidth(bytesRead, operationDuration);
  17. return bytesRead;
  18. }
  19. catch (AggregateException e) {
  20. if (e.InnerException != null) writeTask.ReaderException = e.InnerException;
  21. else writeTask.ReaderException = e;
  22. volumeHealthReport.ReadStatistics.IncrementErrorCount();
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement