public static EnumerateBlobs ( Logger log, Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer container, string prefix, bool>.Func |
||
log | Logger | |
container | Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer | |
prefix | string | |
condition | bool>.Func | |
Результат | IEnumerable |
public override void ExecuteCommand() { var destClient = DestinationStorage.CreateCloudBlobClient(); var destContainer = destClient.GetContainerReference(DestinationContainer); // Iterate through the blobs int index = 0; var blobs = Util.EnumerateBlobs(Log, destContainer, Prefix ?? String.Empty); Parallel.ForEach(blobs, new ParallelOptions() { MaxDegreeOfParallelism = 10 }, blob => { Interlocked.Increment(ref index); if (blob.CopyState.Status != CopyStatus.Pending) { DateTime start = DateTime.UtcNow; int counter = 0; while (blob.CopyState.Status == CopyStatus.Pending) { Thread.Sleep(1000); counter++; blob.FetchAttributes(); if (counter % 5 == 0) { Log.Info("{1}Waiting on {0} ...", blob.Name, counter > 5 ? "Still " : ""); } } if (counter > 2) { Log.Info("Copy of {0} has finished!", blob.Name); } } index++; }); Log.Info("{0} Copies Complete!", index); }