public Task CheckScheduleQueue()
 {
     return(Task.Run(() =>
     {
         var scheduleerNotification = GetLatestQueueMessage();
         if (scheduleerNotification != null)
         {
             _communicationProcessor.SendDailyDigests(scheduleerNotification.ClientRequestId);
             MessageService.DeleteMessage(scheduleerNotification.MessageId, scheduleerNotification.PopReceipt);
         }
     }));
 }
        public Task CheckScheduleQueue()
        {
            return(Task.Run(() =>
            {
                var schedulerNotification = GetLatestQueueMessage();

                if (schedulerNotification == null)
                {
                    return;
                }

                var tasks = new List <Task>
                {
                    new Task(() => _communicationProcessor.SendDailyDigests(schedulerNotification.ClientRequestId)),
                    new Task(() => _communicationProcessor.SendSavedSearchAlerts(schedulerNotification.ClientRequestId))
                };

                tasks.ForEach(t => t.Start());
                Task.WaitAll(tasks.ToArray());

                MessageService.DeleteMessage(ScheduledJobQueues.DailyDigest, schedulerNotification.MessageId, schedulerNotification.PopReceipt);
            }));
        }