public override void ExecuteCommand()

in Source/NuGetGallery.Operations/Tasks/CheckBlobCopiesTask.cs [36:71]


        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);
        }