Esempio n. 1
0
 /// <summary>
 /// Puts the lease on the given blob in a leased state.
 /// </summary>
 /// <param name="blob">The blob 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(CloudBlob blob, TimeSpan? leaseTime)
 {
     string leaseId = Guid.NewGuid().ToString();
     SetAvailableStateAPM(blob);
     IAsyncResult result;
     using (AutoResetEvent waitHandle = new AutoResetEvent(false))
     {
         result = blob.BeginAcquireLease(leaseTime, leaseId, ar => waitHandle.Set(), null);
         waitHandle.WaitOne();
     }
     return blob.EndAcquireLease(result);
 }