1
我在CloudQueueClient类中看到了许多参考文献,例如在“ListQueuesSegmented”和“ListQueuesSegmentedAsync”方法中提及术语“结果段”。但是我没有找到有关如何使用这些功能的有意义的例子。任何Azure专家都可以解释吗?CloudQueueClient类中“结果段”的含义
感谢
德里克
我在CloudQueueClient类中看到了许多参考文献,例如在“ListQueuesSegmented”和“ListQueuesSegmentedAsync”方法中提及术语“结果段”。但是我没有找到有关如何使用这些功能的有意义的例子。任何Azure专家都可以解释吗?CloudQueueClient类中“结果段”的含义
感谢
德里克
当你创建一个存储帐户,您可以创建队列的数量不受限制内(见storage limits了解更多信息)。
比方说您想获得的所有队列的信息,您可以使用CloudQueueClient.ListQueues
方式,通过所有的队列进行迭代:
var storageAccount = CloudStorageAccount.Parse("MyConnectionString");
var queueClient = storageAccount.CreateCloudQueueClient();
foreach(var queue in queueClient.ListQueues())
{
// Do something
}
想象一下,你有一千个队列,你可能不希望执行此请求,因为它可以超时,达到一些限制。
该方法的全部目的是Segmented
方法。它会返回第一个X元素+一个令牌,允许您请求下一个X元素。
当您使用表格显示数据时(在UI端),有时您必须使用分页,因为您的表格可能太大而无法完全显示:这是相同的概念。
// Initialize a new token
var continuationToken = new QueueContinuationToken();
// Execute the query
var segment = queueClient.ListQueuesSegmented(continuationToken);
// Get the new token in order to get the next segment
continuationToken = segment.ContinuationToken;
// Get the results
var queues = segment.Results.ToList();
// do something
...
// Execute the query again with the comtinuation token to fetch next results
segment = queueClient.ListQueuesSegmented(continuationToken);
:
所以,如果你想使用它现在