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

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

private static TryAcquireLease ( this blob, int maximumStopDurationEstimateSeconds ) : string
blob this
maximumStopDurationEstimateSeconds int
Результат string
        private static string TryAcquireLease(this CloudBlob blob, int maximumStopDurationEstimateSeconds)
        {
            try
            {
                var leaseId = blob.AcquireLease(TimeSpan.FromSeconds(35), null, AccessCondition.GenerateEmptyCondition(), leaseRequestTimeout);
                blob.Metadata[leasedForTestTag] = "True";
                blob.SetMetadata(AccessCondition.GenerateLeaseCondition(leaseId), leaseRequestTimeout);

                cancellationTokenSource = new CancellationTokenSource();
                var cancellationToken = cancellationTokenSource.Token;

                leasingTask = Task.Factory.StartNew(t => AutoRenewLease(blob, leaseId, maximumStopDurationEstimateSeconds, cancellationToken), cancellationToken, TaskCreationOptions.LongRunning);
                
                return leaseId;
            }
            catch (StorageClientException storageException)
            {
                var webException = storageException.InnerException as WebException;
                if (webException == null || webException.Response == null || ((HttpWebResponse)webException.Response).StatusCode != HttpStatusCode.Conflict) // 409, already leased
                {
                    BreakLease(blob);
                    throw;
                }
                webException.Response.Close();
                return null;
            }
        }