本文整理汇总了C#中Blob.TryDelete方法的典型用法代码示例。如果您正苦于以下问题:C# Blob.TryDelete方法的具体用法?C# Blob.TryDelete怎么用?C# Blob.TryDelete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Blob
的用法示例。
在下文中一共展示了Blob.TryDelete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveMessage
public void RemoveMessage(Message message)
{
while (true)
{
// find the blobs
List<KeyValuePair<DateTime, CloudBlob>> blobsList = GetBlobs();
if (!blobsList.Any())
return;
int blobIndex = blobsList.IndexOf(blobsList.Last(p => p.Key <= message.Date));
// inserte data
Blob<MessageSet> blob = new Blob<MessageSet>(blobsList[blobIndex].Value);
MessageSet set;
try
{
do
{
set = GetMessageSet(blob);
set.Remove(message);
// merge if necessary -- and if it is possible
// TODO : should we move this to the worker
if (set.Count < mergeSize && blobIndex < blobsList.Count-1 )
{
Blob<MessageSet> blob2 = new Blob<MessageSet>(blobsList[blobIndex + 1].Value);
MessageSet set2 = blob2.GetIfExists(new VersionHasChanged());
// set version to 0 to be sure no one insert/remove a message while we split
blob.AddMetadata("version", Guid.Empty.ToString());
if (!blob.TryUploadMetadata())
throw new VersionHasChanged();
if (!blob2.TryDelete())
{
// restore old version
blob.AddMetadata("version", Guid.NewGuid().ToString());
blob.UploadMetadata();
throw new VersionHasChanged();
}
// specify new versions numbers
blob.AddMetadata("version", Guid.NewGuid().ToString());
set.UnionWith(set2);
blob.Set(set);
return;
}
} while (!blob.TrySet(set));
}
catch (VersionHasChanged) { continue; }
return;
}
}