コード例 #1
0
 public ScheduledTask(ITaskBucket taskBucket, Func <TService, Task> asyncAction, Action <ITaskOptionsBuilder> optionsFactory = null)
 {
     _taskBucket     = taskBucket;
     _asyncAction    = asyncAction;
     _optionsFactory = optionsFactory;
 }
コード例 #2
0
 public ScheduledTask(ITaskBucket taskBucket, Action <TService> syncAction, Action <ITaskOptionsBuilder> optionsFactory = null)
 {
     _taskBucket     = taskBucket;
     _syncAction     = syncAction;
     _optionsFactory = optionsFactory;
 }
コード例 #3
0
        /// <summary>
        /// Adds the specified action as a scheduled task to <see cref="ITaskBucket"/>.
        /// </summary>
        /// <typeparam name="TService">The service to be retrieved from Dependency Injection.</typeparam>
        /// <param name="action">The action to be executed on a schedule.</param>
        /// <param name="optionsFactory">Configures the options to be used by the Scheduled Task.</param>
        /// <returns>A <see cref="ITaskSchedule"/> to be used for setting the schedule.</returns>
        public static IScheduledTask AddScheduledTask <TService>(this IApplicationBuilder app, Action <TService> action, Action <ITaskOptionsBuilder> optionsFactory = null)
        {
            ITaskBucket taskBucket = (ITaskBucket)app.ApplicationServices.GetService(typeof(ITaskBucket));

            return(new ScheduledTask <TService>(taskBucket, action, optionsFactory));
        }