/// <summary>
 /// Puts the lease on the given blob in a released state.
 /// </summary>
 /// <param name="blob">The blob with the lease.</param>
 /// <param name="leaseTime">The amount of time on the released lease.</param>
 /// <returns>The lease ID of the released lease.</returns>
 internal static string SetReleasedStateAPM(ICloudBlob blob, TimeSpan? leaseTime)
 {
     string leaseId = SetLeasedStateAPM(blob, leaseTime);
     IAsyncResult result;
     using (AutoResetEvent waitHandle = new AutoResetEvent(false))
     {
         result = blob.BeginReleaseLease(AccessCondition.GenerateLeaseCondition(leaseId), ar => waitHandle.Set(), null);
         waitHandle.WaitOne();
         blob.EndReleaseLease(result);
         return leaseId;
     }
 }