Example #1
0
        private static void Enqueue(EmailMessage message)
        {
            var emailQueue = DataController.GetEmailQueue();

            using (var memoryStream = new MemoryStream())
            {
                EmailMessage.Serialize(memoryStream, message);

                emailQueue.AddMessage(new CloudQueueMessage(memoryStream.ToArray()));
            }
        }
Example #2
0
        public static IEnumerable <DequeuedMessage> Dequeue(int count)
        {
            var emailQueue = DataController.GetEmailQueue();

            var messages = emailQueue.GetMessages(count);

            foreach (var message in messages)
            {
                using (var memoryStream = new MemoryStream(message.AsBytes))
                {
                    var emailMessage = EmailMessage.Deserialize(memoryStream);
                    yield return(new DequeuedMessage(message, emailQueue, emailMessage));
                }
            }
        }