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


C# CloudQueue.FetchAttributes方法代码示例

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


在下文中一共展示了CloudQueue.FetchAttributes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getQueueLength

        protected static int getQueueLength(CloudQueue queue)
        {
            queue.FetchAttributes();
            var messageCount = queue.ApproximateMessageCount;

            return messageCount ?? 0;
        }
开发者ID:NewMediaCenterMoscow,项目名称:UniSocial3,代码行数:7,代码来源:Program.cs

示例2: FetchAttributes

 /// <summary>
 /// Fetch queue attributes
 /// </summary>
 /// <param name="queue">Cloud queue object</param>
 /// <param name="options">Queue request options</param>
 /// <param name="operationContext">Operation context</param>
 public void FetchAttributes(CloudQueue queue, QueueRequestOptions options, OperationContext operationContext)
 {
     queue.FetchAttributes(options, operationContext);
 }
开发者ID:ranjitk9,项目名称:azure-sdk-tools,代码行数:10,代码来源:StorageQueueManagement.cs

示例3: ProcessBatchOfMessagesAsync

        /// <summary>
        /// Demonstrate adding a number of messages, checking the message count and batch retrieval of messages. During retrieval we 
        /// also set the visibility timeout to 5 minutes. Visibility timeout is the amount of time message is not visible to other 
        /// clients after a GetMessageOperation assuming DeleteMessage is not called. 
        /// </summary>
        /// <param name="queue">The sample queue</param>
        private static async Task ProcessBatchOfMessagesAsync(CloudQueue queue)
        {
            // Enqueue 20 messages by which to demonstrate batch retrieval
            Console.WriteLine("7. Enqueue 20 messages.");
            for (int i = 0; i < 20; i++)
            {
                await queue.AddMessageAsync(new CloudQueueMessage(string.Format("{0} - {1}", i, "Hello World")));
            }

            // The FetchAttributes method asks the Queue service to retrieve the queue attributes, including an approximation of message count 
            Console.WriteLine("8. Get the queue length");
            queue.FetchAttributes();
            int? cachedMessageCount = queue.ApproximateMessageCount;
            Console.WriteLine("Number of messages in queue: {0}", cachedMessageCount);

            // Dequeue a batch of 21 messages (up to 32) and set visibility timeout to 5 minutes. Note we are dequeuing 21 messages because the earlier
            // UpdateEnqueuedMessage method left a message on the queue hence we are retrieving that as well. 
            Console.WriteLine("9. Dequeue 21 messages, allowing 5 minutes for the clients to process.");
            foreach (CloudQueueMessage msg in await queue.GetMessagesAsync(21, TimeSpan.FromMinutes(5), null, null))
            {
                Console.WriteLine("Processing & deleting message with content: {0}", msg.AsString);

                // Process all messages in less than 5 minutes, deleting each message after processing.
                await queue.DeleteMessageAsync(msg);
            }
        }
开发者ID:tamram,项目名称:storage-queue-dotnet-getting-started,代码行数:32,代码来源:Program.cs


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