예제 #1
0
        /// <summary>
        /// Schedules an action to be invoked after an initial delay and then repeatedly.
        /// </summary>
        /// <param name="scheduler">The scheduler</param>
        /// <param name="initialMillisecondsDelay">The time in milliseconds that has to pass before first invocation.</param>
        /// <param name="millisecondsInterval">The interval, i.e. the time in milliseconds that has to pass between the action is invoked.</param>
        /// <param name="action">The action to perform.</param>
        /// <returns>A cancelable that can be used to cancel the action from being executed</returns>
        public static ICancelable ScheduleRepeatedlyCancelable(this IActionScheduler scheduler, int initialMillisecondsDelay, int millisecondsInterval, Action action)
        {
            var cancelable = new Cancelable(scheduler);

            scheduler.ScheduleRepeatedly(initialMillisecondsDelay, millisecondsInterval, action, cancelable);
            return(cancelable);
        }
예제 #2
0
        /// <summary>
        /// Schedules an action to be invoked after an initial delay and then repeatedly.
        /// </summary>
        /// <param name="scheduler">The scheduler</param>
        /// <param name="initialDelay">The time period that has to pass before first invocation.</param>
        /// <param name="interval">The interval, i.e. the time period that has to pass between the action is invoked.</param>
        /// <param name="action">The action to perform.</param>
        /// <returns>A cancelable that can be used to cancel the action from being executed</returns>
        public static ICancelable ScheduleRepeatedlyCancelable(this IActionScheduler scheduler, TimeSpan initialDelay, TimeSpan interval, Action action)
        {
            var cancelable = new Cancelable(scheduler);

            scheduler.ScheduleRepeatedly(initialDelay, interval, action, cancelable);
            return(cancelable);
        }
예제 #3
0
 /// <summary>
 /// Schedules an action to be invoked after an initial delay and then repeatedly.
 /// The action will be wrapped so that it completes inside the currently active actor if it is called from within an actor
 /// <remarks>Note! It's considered bad practice to use concurrency inside actors, and very easy to get wrong so usage is discouraged.</remarks>
 /// </summary>
 /// <param name="scheduler">The scheduler</param>
 /// <param name="initialMillisecondsDelay">The time in milliseconds that has to pass before first invocation.</param>
 /// <param name="millisecondsInterval">The interval, i.e. the time in milliseconds that has to pass before the action is invoked again.</param>
 /// <param name="action">The action to perform.</param>
 /// <param name="cancelable">OPTIONAL. A cancelable that can be used to cancel the action from being executed. Defaults to <c>null</c></param>
 public static void ScheduleRepeatedly(this IActionScheduler scheduler, int initialMillisecondsDelay, int millisecondsInterval, Action action, ICancelable cancelable = null)
 {
     scheduler.ScheduleRepeatedly(TimeSpan.FromMilliseconds(initialMillisecondsDelay), TimeSpan.FromMilliseconds(millisecondsInterval), action, cancelable);
 }