private IEnumerable <IListBlockItem <TItem> > GetItemsFromHeaderlessBlock(params ItemStatus[] statuses) { if (statuses.Length == 0) { statuses = new[] { ItemStatus.All } } ; lock (_getItemsSyncRoot) { if (_headerlessBlock.Items == null || !_headerlessBlock.Items.Any()) { var protoListBlockItems = _listBlockRepository.GetListBlockItems(new TaskId(_applicationName, _taskName), ListBlockId); _headerlessBlock.Items = Convert(protoListBlockItems); foreach (var item in _headerlessBlock.Items) { ((ListBlockItem <TItem>)item).SetParentContext(this.ItemComplete, this.ItemFailed, this.DiscardItem); } } if (statuses.Any(x => x == ItemStatus.All)) { return(_headerlessBlock.Items.Where(x => x.Status == ItemStatus.Failed || x.Status == ItemStatus.Pending || x.Status == ItemStatus.Discarded || x.Status == ItemStatus.Completed).ToList()); } return(_headerlessBlock.Items.Where(x => statuses.Contains(x.Status)).ToList()); } }