コード例 #1
0
        private async Task <IEnumerable <QueueMessage> > ReceiveMessagesWithLinearBackOffAsync()
        {
            var currentBackOffInSeconds = 0;
            var messages = new QueueMessage[0];

            while (!messages.Any())
            {
                await Task.Delay(TimeSpan.FromSeconds(Math.Min(currentBackOffInSeconds++, _maximumBackOffDurationInSeconds)), _cancellationToken);

                messages = (await _queueClient.ReceiveMessagesAsync(_maximumReceiveBatchSize, TimeSpan.FromSeconds(_invisibilityTimeoutInSeconds), _cancellationToken)).Value;
            }

            return(messages);
        }