Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- int bytesRead = 0;
- var operationStart = DateTime.Now;
- var vt = sourceFile.ReadAsync(writeTask.Data);
- if (vt.IsCompletedSuccessfully) {
- bytesRead = vt.Result;
- }
- else {
- var t = vt.AsTask();
- if (!t.Wait(State.TransferTimeoutSeconds * 1000))
- throw new AggregateException(new TimeoutException("Reader timed out."));
- bytesRead = t.Result;
- }
- writeTask.Data = writeTask.Data.Slice(0, bytesRead);
- var operationDuration = (DateTime.Now - operationStart);
- volumeHealthReport.ReadStatistics.UpdateBandwidth(bytesRead, operationDuration);
- return bytesRead;
- }
- catch (AggregateException e) {
- if (e.InnerException != null) writeTask.ReaderException = e.InnerException;
- else writeTask.ReaderException = e;
- volumeHealthReport.ReadStatistics.IncrementErrorCount();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement