当前位置: 首页>>代码示例>>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;未经允许,请勿转载。