本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Queue.CloudQueueClient.ListQueuesSegmentedAsync方法的典型用法代码示例。如果您正苦于以下问题:C# CloudQueueClient.ListQueuesSegmentedAsync方法的具体用法?C# CloudQueueClient.ListQueuesSegmentedAsync怎么用?C# CloudQueueClient.ListQueuesSegmentedAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.Storage.Queue.CloudQueueClient
的用法示例。
在下文中一共展示了CloudQueueClient.ListQueuesSegmentedAsync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ListQueuesSample
/// <summary>
/// Create, list and delete queues
/// </summary>
/// <param name="cloudQueueClient"></param>
/// <returns></returns>
private static async Task ListQueuesSample(CloudQueueClient cloudQueueClient)
{
// Create 3 queues.
// Create the queue name -- use a guid in the name so it's unique.
string baseQueueName = "demotest-" + System.Guid.NewGuid().ToString();
// Keep a list of the queues so you can compare this list
// against the list of queues that we retrieve.
List<string> queueNames = new List<string>();
for (int i = 0; i < 3; i++)
{
// Set the name of the queue, then add it to the generic list.
string queueName = baseQueueName + "-0" + i;
queueNames.Add(queueName);
// Create the queue with this name.
Console.WriteLine("Creating queue with name {0}", queueName);
CloudQueue cloudQueue = cloudQueueClient.GetQueueReference(queueName);
try
{
await cloudQueue.CreateIfNotExistsAsync();
Console.WriteLine(" Queue created successfully.");
}
catch (StorageException exStorage)
{
Common.WriteException(exStorage);
Console.WriteLine(
"Please make sure your storage account is specified correctly in the app.config - then restart the sample.");
Console.WriteLine("Press any key to exit");
Console.ReadLine();
throw;
}
catch (Exception ex)
{
Console.WriteLine(" Exception thrown creating queue.");
Common.WriteException(ex);
throw;
}
}
Console.WriteLine(string.Empty);
Console.WriteLine("List of queues in the storage account:");
// List the queues for this storage account
QueueContinuationToken token = null;
List<CloudQueue> cloudQueueList = new List<CloudQueue>();
do
{
QueueResultSegment segment = await cloudQueueClient.ListQueuesSegmentedAsync(baseQueueName, token);
token = segment.ContinuationToken;
cloudQueueList.AddRange(segment.Results);
}
while (token != null);
try
{
foreach (CloudQueue cloudQ in cloudQueueList)
{
Console.WriteLine("Cloud Queue name = {0}", cloudQ.Name);
}
}
catch (Exception ex)
{
Console.WriteLine(" Exception thrown listing queues.");
Common.WriteException(ex);
throw;
}
// Now clean up after yourself, using the list of queues that you created in case there were other queues in the account.
foreach (string oneQueueName in queueNames)
{
CloudQueue cloudQueue = cloudQueueClient.GetQueueReference(oneQueueName);
cloudQueue.DeleteIfExists();
}
}