コード例 #1
0
        public IAsyncResult BeginGetMessages(int messageCount, TimeSpan visibilityTimeout, AsyncCallback callback,
                                             object state)
        {
            CloudQueue        queue   = _queues[GetNextQueue()];
            NestedAsyncHelper wrapper = NestedAsyncHelper.WrapBeginParameters(callback, state, queue);

            return
                (wrapper.WrapAsyncResult(queue.BeginGetMessages(messageCount, visibilityTimeout,
                                                                NestedAsyncHelper.Callback, wrapper)));
        }
コード例 #2
0
        CloudQueueMessage GetMessage()
        {
            CloudQueueMessage cloudQueueMessage;

            if (batchQueue.TryDequeue(out cloudQueueMessage))
            {
                return(cloudQueueMessage);
            }
            var callback = new AsyncCallback(ar =>
            {
                var receivedMessages = azureQueue.EndGetMessages(ar);
                foreach (var receivedMessage in receivedMessages)
                {
                    batchQueue.Enqueue(receivedMessage);
                }
            });

            azureQueue.BeginGetMessages(BatchSize, TimeSpan.FromMilliseconds(MessageInvisibleTime * BatchSize), null, null, callback, null);
            return(null);
        }