本文整理汇总了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);
}
}
}
示例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));
}
}
示例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));
}
}
示例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");
}
}