Exemple #1
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));
 }
Exemple #2
0
 public Task Scan()
 {
     Stopped.Value = false;
     return(Task.Factory.StartNew(state =>
     {
         if (!((InternalStop)state).Value)
         {
             BacklogQueue.Scan();
             InProcessQueue.Scan(); // for directly insert data to db
             if (_firstRun)
             {
                 _firstRun = false;
                 RealTimeQueue.Scan();
                 EmailMessage message;
                 while (!((InternalStop)state).Value && RealTimeQueue.Dequeue(out message))
                 {
                     InProcessQueue.Enqueue(message);
                 }
             }
         }
     }, Stopped, TaskCreationOptions.AttachedToParent));
 }