当前位置: 首页>>代码示例>>C#>>正文


C# CloudBlockBlob.AcquireLease方法代码示例

本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.AcquireLease方法的典型用法代码示例。如果您正苦于以下问题:C# CloudBlockBlob.AcquireLease方法的具体用法?C# CloudBlockBlob.AcquireLease怎么用?C# CloudBlockBlob.AcquireLease使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob的用法示例。


在下文中一共展示了CloudBlockBlob.AcquireLease方法的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: RenewingBlobLease

		public RenewingBlobLease(CloudBlockBlob blob)
		{
			_log = this.GetLogger();
			_blob = blob;
			Id = _blob.AcquireLease(TimeSpan.FromSeconds(40), null);
			_log.DebugEvent("AcquiredLease", new Facet("blobUri", _blob.Uri), new Facet("leaseId", Id));

			_timer = new Timer(TimeSpan.FromSeconds(30).TotalMilliseconds);
			_timer.Elapsed += RenewLease;
			_timer.Start();
		}
开发者ID:smartpcr,项目名称:bigdata2,代码行数:11,代码来源:RenewingBlobLease.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: TryAcquireLease

    public bool TryAcquireLease(CloudBlockBlob blob, double leaseTimeInSeconds)
    {
        if(leaseTimeInSeconds < 15 || leaseTimeInSeconds > 60)
            throw new ArgumentException(@"value must be greater than 15 and smaller than 60", 
                                        "leaseTimeInSeconds");
        try
        {
            string proposedLeaseId = Guid.NewGuid().ToString();

            var leaseTime = TimeSpan.FromSeconds(leaseTimeInSeconds);
            string leaseId = blob.AcquireLease(leaseTime,
                                                        proposedLeaseId);

            UpdateAcquiredLease(blob, leaseId, leaseTimeInSeconds);
                
            return true;
        }
        catch (StorageException)
        {
            Trace.WriteLine(string.Format(FAILED_TO_ACQUIRE_LEASE, blob.Name));
            return false;
        }
    }
开发者ID:hossamdarwish,项目名称:Brisebois.WindowsAzure,代码行数:23,代码来源:BlobLeaseManager.cs


注:本文中的Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.AcquireLease方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。