Example #1
0
        private static IResultAccessor <T> CreateCondition(Func <T, int, bool> condition, IListItemSetterManager <T> manager)
        {
            var c = new ListCondition <T>(condition);

            manager.Add(c);
            return(c);
        }
Example #2
0
        private IResultAccessor <T> CreateAddInsertCondition(Func <T, int, bool> condition, IListItemSetterManager <T> manager)
        {
            var c = new ListCondition <T>(condition);

            // Go through all of the existing items to see if this condition
            // has already been met. Otherwise the caller could potentially
            // wait forever.
            bool conditionNotMet = true;

            for (int index = 0; index < list.Count; index++)
            {
                if (c.TrySetResult(list[index], index))
                {
                    conditionNotMet = false;
                }
            }

            // The condition was not met by any of the items in the list.
            // Add the condition to the manager to be monitored.
            if (conditionNotMet)
            {
                manager.Add(c);
            }

            return(c);
        }