Пример #1
0
 /// <summary>
 /// Puts the lease on the given container in a leased state.
 /// </summary>
 /// <param name="container">The container with the lease.</param>
 /// <param name="leaseTime">The amount of time on the new lease.</param>
 /// <returns>The lease ID of the current lease.</returns>
 internal static string SetLeasedStateAPM(CloudBlobContainer container, TimeSpan? leaseTime)
 {
     string leaseId = Guid.NewGuid().ToString();
     SetUnleasedStateAPM(container);
     using (AutoResetEvent waitHandle = new AutoResetEvent(false))
     {
         IAsyncResult result = container.BeginAcquireLease(leaseTime, leaseId, ar => waitHandle.Set(), null);
         waitHandle.WaitOne();
         return container.EndAcquireLease(result);
     }
 }