當前位置: 首頁>>代碼示例>>C#>>正文


C# CloudBlockBlob.ReleaseLease方法代碼示例

本文整理匯總了C#中Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.ReleaseLease方法的典型用法代碼示例。如果您正苦於以下問題:C# CloudBlockBlob.ReleaseLease方法的具體用法?C# CloudBlockBlob.ReleaseLease怎麽用?C# CloudBlockBlob.ReleaseLease使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob的用法示例。


在下文中一共展示了CloudBlockBlob.ReleaseLease方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: uploadfromFilesystem

 public void uploadfromFilesystem(CloudBlockBlob blob, string localFilePath, string eventType)
 {
     if (eventType.Equals("create") || eventType.Equals("signUpStart"))
     {
         Program.ClientForm.addtoConsole("Upload started[create || signUpStart]:" + localFilePath);
         blob.UploadFromFile(localFilePath, FileMode.Open);
         Program.ClientForm.addtoConsole("Uploaded");
         Program.ClientForm.ballon("Uploaded:"+ localFilePath);
     }
     else
     {
         try
         {
             Program.ClientForm.addtoConsole("Upload started[change,etc]:" + localFilePath);
             string leaseId = Guid.NewGuid().ToString();
             blob.AcquireLease(TimeSpan.FromMilliseconds(16000), leaseId);
             blob.UploadFromFile(localFilePath, FileMode.Open, AccessCondition.GenerateLeaseCondition(leaseId));
             blob.ReleaseLease(AccessCondition.GenerateLeaseCondition(leaseId));
             Program.ClientForm.addtoConsole("Uploaded");
             Program.ClientForm.ballon("Uploaded:" + localFilePath);
         }
         catch (Exception ex)
         {
             Program.ClientForm.addtoConsole("Upload: second attempt");
             Thread.Sleep(5000);
             string leaseId = Guid.NewGuid().ToString();
             blob.AcquireLease(TimeSpan.FromMilliseconds(16000), leaseId);
             blob.UploadFromFile(localFilePath, FileMode.Open, AccessCondition.GenerateLeaseCondition(leaseId));
             blob.ReleaseLease(AccessCondition.GenerateLeaseCondition(leaseId));
             Program.ClientForm.addtoConsole("Uploaded");
             Program.ClientForm.ballon("Uploaded:" + localFilePath);
         }
     }
 }
開發者ID:hangmiao,項目名稱:DBLike,代碼行數:34,代碼來源:LocalFileSys.cs

示例2: ReleaseLease

    public void ReleaseLease(CloudBlockBlob blob)
    {
        if (!HasLease(blob)) return;

        string leaseId = GetLeaseId(blob);

        ClearLease(blob);

        try
        {
            blob.ReleaseLease(new AccessCondition
            {
                LeaseId = leaseId
            });
        }
        catch (StorageException)
        {
            Trace.WriteLine(string.Format(FAILED_ATTEMPT_AT_RELEASING_BLOB_LEASE,
                                          blob.Name,
                                          leaseId));
        }
    }
開發者ID:hossamdarwish,項目名稱:Brisebois.WindowsAzure,代碼行數:22,代碼來源:BlobLeaseManager.cs

示例3: Leased

 public static void Leased(CloudBlockBlob blob, Action<CloudBlockBlob> a)
 {
     var lease = blob.AcquireLease(TimeSpan.FromSeconds(60), null);
     try
     {
         a(blob);
     }
     finally
     {
         blob.ReleaseLease(AccessCondition.GenerateLeaseCondition(lease));
     }
 }
開發者ID:philipnilsson,項目名稱:N2AzureFileSystem,代碼行數:12,代碼來源:Program.cs

示例4: ReleaseLockInternal

        private void ReleaseLockInternal(LockArgs lockArgs, LockContext context, CloudBlockBlob blob, string leaseId)
        {
            context.AutoRenew = false;
            var releaseTask = new Task(() =>
            {
                blob.ReleaseLease(new AccessCondition() { LeaseId = leaseId });
                if (LockReleased != null) LockReleased(lockArgs);
            });

            if (LockReleaseMode == AzureStorage.LockReleaseMode.Asyncronous)
            {
                releaseTask.Start();
            }
            else if (LockReleaseMode == AzureStorage.LockReleaseMode.Syncronous)
            {
                releaseTask.RunSynchronously();
            }
            else if (LockReleaseMode == AzureStorage.LockReleaseMode.LetExpire)
            {
                // Do nothing
            }
            else
            {
                throw new NotImplementedException("There should not be a possibility for an else");
            }
        }
開發者ID:adamabdelhamed,項目名稱:Sucrose,代碼行數:26,代碼來源:CloudLockManager.cs


注:本文中的Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.ReleaseLease方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。