예제 #1
0
        private static ScheduledFunction <T> Add <T>(
            bool isFunction,
            [NotNull] ScheduledFunction <T> .SchedulableDueCancellableFunctionAsync function,
            [NotNull] ISchedule schedule,
            int maximumHistory       = -1,
            Duration maximumDuration = default(Duration))
        {
            if (function == null)
            {
                throw new ArgumentNullException("function");
            }
            if (schedule == null)
            {
                throw new ArgumentNullException("schedule");
            }

            ScheduledFunction <T> sf = new ScheduledFunction <T>(
                isFunction,
                function,
                schedule,
                maximumHistory < 1 ? _defaultMaximumHistory : maximumHistory,
                maximumDuration <= Duration.Zero ? _defaultMaximumDuration : maximumDuration);

            // Update actions dictionary
            _actions.AddOrUpdate(sf.ID, sf, (i, a) => sf);

            // Calculate next due
            sf.RecalculateNextDue(Instant.MinValue);
            return(sf);
        }