protected override void DoWork() { using (ITracer activity = this.tracer.StartActivity("ReadFiles", EventLevel.Informational)) { int readFilesCurrentThread = 0; int failedFilesCurrentThread = 0; byte[] buffer = new byte[1]; string blobId; while (this.availableBlobs.TryTake(out blobId, Timeout.Infinite)) { foreach (string path in this.blobIdToPaths[blobId]) { bool succeeded = false; using (SafeFileHandle handle = NativeFileReader.Open(path)) { if (!handle.IsInvalid) { succeeded = NativeFileReader.ReadOneByte(handle, buffer); } } if (succeeded) { Interlocked.Increment(ref this.readFileCount); readFilesCurrentThread++; } else { activity.RelatedError("Failed to read " + path); failedFilesCurrentThread++; this.HasFailures = true; } } } activity.Stop( new EventMetadata { { "FilesRead", readFilesCurrentThread }, { "Failures", failedFilesCurrentThread }, }); } }
public override bool HydrateFile(string fileName, byte[] buffer) { return(NativeFileReader.TryReadFirstByteOfFile(fileName, buffer)); }