Beispiel #1
0
 private async Task WatchQueue(int id)
 {
     Running   = true;
     Alive[id] = true;
     while (Running)
     {
         if (queue.TryDequeue(out Message message))
         {
             try
             {
                 onDispatch();
                 message.Action();
             }
             catch (Exception e)
             {
                 var exception = new DispatcherException(message.Dispatchee, message.Trace, e);
                 EnqueueException(exception);
                 onException(e);
             }
         }
         else
         {
             await Task.Delay(pollingDelay);
         }
     }
     Alive[id] = false;
 }
Beispiel #2
0
 private void EnqueueException(DispatcherException exception)
 {
     lock (faultLock)
     {
         if (faults.Count >= faultBufferSize)
         {
             faults.Dequeue();
         }
         faults.Enqueue(exception);
     }
 }