Esempio n. 1
0
 private Task ProcessInProcess()
 {
     return(Task.Factory.StartNew(state =>
     {
         if (!((InternalStop)state).Value)
         {
             EmailMessage message = null;
             while (InProcessQueue.Dequeue(out message) && !((InternalStop)state).Value)
             {
                 try
                 {
                     RealTimeQueue.Enqueue(message);
                     MailClient.Send(message);
                     SuccessQueue.Enqueue(message);
                     Thread.Sleep((int)(1000 * MailSettings.SmtpInterval));
                 }
                 catch (Exception)
                 {
                     FailureQueue.Enqueue(message);
                     throw;
                 }
                 finally
                 {
                     RealTimeQueue.Dequeue(out message);
                 }
             }
         }
     }, Stopped, TaskCreationOptions.AttachedToParent | TaskCreationOptions.LongRunning));
 }
Esempio n. 2
0
 private Task ProcessBacklog()
 {
     return(Task.Factory.StartNew(state =>
     {
         if (!((InternalStop)state).Value)
         {
             EmailMessage message = null;
             while (BacklogQueue.Dequeue(out message) && !((InternalStop)state).Value)
             {
                 try
                 {
                     InProcessQueue.Enqueue(message);
                 }
                 catch (Exception)
                 {
                     FailureQueue.Enqueue(message);
                     throw;
                 }
             }
         }
     }, Stopped, TaskCreationOptions.AttachedToParent));
 }