public async Task <QueueObject <T> > Pop(TimeSpan?invisibleTimeSpan = null, Action <QueueObject <T> > action = null) { CloudQueue queue = await GetQueueAsync(); CloudQueueMessage peekedMessage = await queue.GetMessageAsync(invisibleTimeSpan ?? TimeSpan.FromSeconds(3), new QueueRequestOptions(), new OperationContext()); if (peekedMessage != null) { QueueObject <T> queueObject = JsonConvert.DeserializeObject <QueueObject <T> >(peekedMessage.AsString); if (action != null) { try { action(queueObject); await queue.DeleteMessageAsync(peekedMessage); } catch (Exception ex) { throw ex; } } return(queueObject); } else { return(null); } }
public async Task Push(QueueObject <T> queueObject) { CloudQueue queue = await GetQueueAsync(); var text = JsonConvert.SerializeObject(queueObject); CloudQueueMessage message = new CloudQueueMessage(text); await queue.AddMessageAsync(message); }