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


C# CloudQueue.GetMessageAsync方法代码示例

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


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

示例1: UpdateEnqueuedMessageAsync

        private static async Task UpdateEnqueuedMessageAsync(CloudQueue queue)
        {
            Console.WriteLine("5. Insert another test message ");
            await queue.AddMessageAsync(new CloudQueueMessage("Hello World Again!"));

            Console.WriteLine("6. Change the contents of a queued message");
            CloudQueueMessage message = await queue.GetMessageAsync();

            message.SetMessageContent("Updated contents.");
            await queue.UpdateMessageAsync(message, TimeSpan.Zero, MessageUpdateFields.Content | MessageUpdateFields.Visibility);
        }
开发者ID:techieshravan,项目名称:azure,代码行数:11,代码来源:Program.cs

示例2: BasicQueueOperationsAsync

        private static async Task BasicQueueOperationsAsync(CloudQueue queue)
        {
            Console.WriteLine("2. Insert a single message into a queue");

            await queue.AddMessageAsync(new CloudQueueMessage("Hello World!"));

            Console.WriteLine("3. Peek at the next message");
            CloudQueueMessage peekedMessage = await queue.PeekMessageAsync();

            if (peekedMessage != null)
            {
                Console.WriteLine("The peeked message is: {0}", peekedMessage.AsString);
            }

            Console.WriteLine("4. De-queue the next message");
            CloudQueueMessage message = await queue.GetMessageAsync();
            if (message != null)
            {
                Console.WriteLine("Processing & deleting message with content: {0}", message.AsString);
                await queue.DeleteMessageAsync(message);
            }
        }
开发者ID:techieshravan,项目名称:azure,代码行数:22,代码来源:Program.cs

示例3: GetMessageWithTimeout

        private async Task<CloudQueueMessage> GetMessageWithTimeout(CloudQueue queue, TimeSpan timeout)
        {
            var queueMessage = await queue.GetMessageAsync();
            if (queueMessage != null)
            {
                return queueMessage;
            }

            var sw = System.Diagnostics.Stopwatch.StartNew();

            var backOffs = new int[] { 1, 1 }//, 3, 5, 10, 10, 30 }
                               .Select(s => TimeSpan.FromSeconds(s)).ToArray();

            int backOffIdx = 0;
            while (queueMessage == null && sw.Elapsed < timeout)
            {
                var delay = backOffIdx < backOffs.Length ? backOffs[backOffIdx] : backOffs[backOffs.Length - 1];
                await Task.Delay(delay);
                queueMessage = await queue.GetMessageAsync();
                backOffIdx++;
            }

            sw.Stop();

            return queueMessage;
        }
开发者ID:jamesholcomb,项目名称:NDomain,代码行数:26,代码来源:QueueTransport.cs

示例4: UpdateEnqueuedMessageAsync

        /// <summary>
        /// Update an enqueued message and its visibility time. For workflow scenarios this could enable you to update 
        /// the status of a task as well as extend the visibility timeout in order to provide more time for a client 
        /// continue working on the message before another client can see the message. 
        /// </summary>
        /// <param name="queue">The sample queue</param>
        private static async Task UpdateEnqueuedMessageAsync(CloudQueue queue)
        {
            // Insert another test message into the queue 
            Console.WriteLine("5. Insert another test message ");
            await queue.AddMessageAsync(new CloudQueueMessage("Hello World Again!"));

            Console.WriteLine("6. Change the contents of a queued message");
            CloudQueueMessage message = await queue.GetMessageAsync();
            message.SetMessageContent("Updated contents.");
            await queue.UpdateMessageAsync(
                message,
                TimeSpan.Zero,  // For the purpose of the sample make the update visible immediately
                MessageUpdateFields.Content |
                MessageUpdateFields.Visibility);
        }
开发者ID:tamram,项目名称:storage-queue-dotnet-getting-started,代码行数:21,代码来源:Program.cs


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