示例#1
0
 public async Task ReleaseLeaseAsync(IStorageBlockBlob blob, string leaseId, CancellationToken cancellationToken)
 {
     try
     {
         // Note that this call returns without throwing if the lease is expired. See the table at:
         // http://msdn.microsoft.com/en-us/library/azure/ee691972.aspx
         await blob.ReleaseLeaseAsync(
             accessCondition : new AccessCondition {
             LeaseId = leaseId
         },
             options : null,
             operationContext : null,
             cancellationToken : cancellationToken);
     }
     catch (StorageException exception)
     {
         if (exception.IsNotFoundBlobOrContainerNotFound())
         {
             // The user deleted the receipt or its container; nothing to release at this point.
         }
         else if (exception.IsConflictLeaseIdMismatchWithLeaseOperation())
         {
             // Another lease is active; nothing for this lease to release at this point.
         }
         else
         {
             throw;
         }
     }
 }
示例#2
0
 private async Task ReleaseLeaseAsync(IStorageBlockBlob blob, string leaseId, CancellationToken cancellationToken)
 {
     try
     {
         // Note that this call returns without throwing if the lease is expired. See the table at:
         // http://msdn.microsoft.com/en-us/library/azure/ee691972.aspx
         await blob.ReleaseLeaseAsync(
             accessCondition : new AccessCondition {
             LeaseId = leaseId
         },
             options : null,
             operationContext : null,
             cancellationToken : cancellationToken);
     }
     catch (StorageException exception)
     {
         if (exception.RequestInformation != null)
         {
             if (exception.RequestInformation.HttpStatusCode == 404 ||
                 exception.RequestInformation.HttpStatusCode == 409)
             {
                 // if the blob no longer exists, or there is another lease
                 // now active, there is nothing for us to release so we can
                 // ignore
             }
             else
             {
                 throw;
             }
         }
         else
         {
             throw;
         }
     }
 }
 private async Task ReleaseLeaseAsync(IStorageBlockBlob blob, string leaseId, CancellationToken cancellationToken)
 {
     try
     {
         // Note that this call returns without throwing if the lease is expired. See the table at:
         // http://msdn.microsoft.com/en-us/library/azure/ee691972.aspx
         await blob.ReleaseLeaseAsync(
             accessCondition: new AccessCondition { LeaseId = leaseId },
             options: null,
             operationContext: null,
             cancellationToken: cancellationToken);
     }
     catch (StorageException exception)
     {
         if (exception.IsNotFoundBlobOrContainerNotFound())
         {
             // The user deleted the receipt or its container; nothing to release at this point.
         }
         else if (exception.IsConflictLeaseIdMismatchWithLeaseOperation())
         {
             // Another lease is active; nothing for this lease to release at this point.
         }
         else
         {
             throw;
         }
     }
 }
示例#4
0
 private async Task ReleaseLeaseAsync(IStorageBlockBlob blob, string leaseId, CancellationToken cancellationToken)
 {
     try
     {
         // Note that this call returns without throwing if the lease is expired. See the table at:
         // http://msdn.microsoft.com/en-us/library/azure/ee691972.aspx
         await blob.ReleaseLeaseAsync(
             accessCondition: new AccessCondition { LeaseId = leaseId },
             options: null,
             operationContext: null,
             cancellationToken: cancellationToken);
     }
     catch (StorageException exception)
     {
         if (exception.RequestInformation != null)
         {
             if (exception.RequestInformation.HttpStatusCode == 404 ||
                 exception.RequestInformation.HttpStatusCode == 409)
             {
                 // if the blob no longer exists, or there is another lease
                 // now active, there is nothing for us to release so we can
                 // ignore
             }
             else
             {
                 throw;
             }
         }
         else
         {
             throw;
         }
     }
 }