Beispiel #1
0
        public void NotifySubscriptionPosted()
        {
            int decrementedCounter;

            if (_postingCount == 0 || !InterlockedUtilities.Decrement(location: ref _completedPostingCountdown, minExclusive: 0, result: out decrementedCounter))
            {
                throw new InvalidOperationException();
            }
            else if (decrementedCounter == 0 && _disposeMessageAtEndOfPosting)
            {
                _message?.Dispose();
            }
        }
Beispiel #2
0
 void P_ProcessQueue()
 {
     TaskUtilities
     .RunOnDefaultScheduler(
         action:
         () => {
         try {
             __IsThreadProcessingTasks = true;
             for (; ;)
             {
                 var task = default(Task);
                 _tasksQueue
                 .UpdateValue(
                     locTaskList => {
                     if (locTaskList.Count < 1)
                     {
                         return(locTaskList);
                     }
                     else
                     {
                         task = locTaskList[0];
                         return(locTaskList.RemoveAt(0));
                     }
                 });
                 if (task == null)
                 {
                     InterlockedUtilities.Decrement(ref _processQueueRunningCount, 0);
                     break;
                 }
                 else
                 {
                     TryExecuteTask(task);
                 }
             }
         }
         finally {
             __IsThreadProcessingTasks = false;
         }
     },
         ct: CancellationToken.None);
 }