/// <summary> /// Check if can process dispatches. Checking limit capacity is done only once while queue is still not empty. /// </summary> /// <param name="checkLimitCapacity"></param> /// <returns></returns> protected virtual bool CanContinue(bool checkLimitCapacity) { List <int> activeDeliveryTypes = _channelRegistry.GetActiveDeliveryTypes(checkLimitCapacity); bool isQueueEmpty = _dispatchQueue.CheckIsEmpty(activeDeliveryTypes); return(!isQueueEmpty && _hubState.State == SwitchState.Started); }
protected virtual bool CheckIsQueryRequired(List <int> activeDeliveryTypes) { bool isEmpty = _dispatchQueue.CheckIsEmpty(activeDeliveryTypes); if (!isEmpty) { return(false); } bool storageUpdated = _changeNotifier != null && _changeNotifier.HasUpdates; DateTime nextQueryTimeUtc = _lastQueryTimeUtc + QueryPeriod; bool doScheduledQuery = nextQueryTimeUtc <= DateTime.UtcNow; bool hasUnqueriedKeys = _lastQueryKeys == null || activeDeliveryTypes.Except(_lastQueryKeys).Count() > 0; return(storageUpdated || doScheduledQuery || hasUnqueriedKeys || _isLastQueryMaxItemsReceived); }