Amido.Testing.Azure.BlobStorage.AutoRenewLease C# (CSharp) Метод

AutoRenewLease() приватный статический Метод

private static AutoRenewLease ( CloudBlob blob, string leaseId, int maximumStopDurationEstimateSeconds, CancellationToken cancellationToken ) : void
blob Microsoft.WindowsAzure.StorageClient.CloudBlob
leaseId string
maximumStopDurationEstimateSeconds int
cancellationToken System.Threading.CancellationToken
Результат void
        private static void AutoRenewLease(CloudBlob blob, string leaseId, int maximumStopDurationEstimateSeconds, CancellationToken cancellationToken)
        {
            try
            {
                const int sleepSeconds = 10;
                var totalSleepSeconds = 0;
                while (true)
                {
                    for (var i = 0; i < sleepSeconds; i++ )
                    {
                        Thread.Sleep(TimeSpan.FromSeconds(1));
                        if (cancellationToken.IsCancellationRequested)
                            break;
                    }
                    totalSleepSeconds += sleepSeconds;
                    if (totalSleepSeconds >= maximumStopDurationEstimateSeconds)
                        break;
                    blob.RenewLease(AccessCondition.GenerateLeaseCondition(leaseId), leaseRequestTimeout);
                }
            }
            catch
            {
            }
            finally
            {
                try
                {
                    BreakLease(blob);
                }
                catch
                {
                }
            }
        }